Encoding Intel x86/IA-32 Assembler Instructions

Translation of the second line is a direct and solved issue. What about jmp 114? Well, we want to jump over the data (18 bytes, one byte per each character in the string.) IASDM tell us (Appendix B) that the opcode for unconditional jumps in the same segment is 11101011, which in hexadecimal, is expressed as EB.

On the post Debugging hello, world, someone asked about the reason for translating the instruction jmp 114 into hexadecimal EB12. To answer this, we are going to recur to the “lovely” and elder Intel Architecture Software Developer Manual (IASDM), Volume 2. This volume describes the instructions set of the Intel Architecture processor (x86/IA-32) and the opcode structure. I’ll review some terms involved here:

    x86: It refers to the instruction set of the Intel-compatible CPU architectures (chips produced by Intel, AMD, VIA, and others) inaugurated by Intel’s original 16-bit 8086 CPU. A decision which proved wise was to make each new instance of x86 processors almost fully backwards compatible.
    IA-32: It is Intel’s 32-bit implementation of the x86 architecture; IA-32 distinguishes this implementation from the preceding 16-bit x86 processors. Note that when the 64-bit era arrived, Intel launched its Itanium processor, which discards compatibility with the IA-32 instruction set. Such 64-bit architecture description and implementation is referred to as IA-64, meaning “Intel Architecture, 64-bit”, but even though the names are similar, IA-32 and IA-64 are very different architectures and instructions sets. However, AMD’s response to Intel 64-bit processors, uses an instruction set that, in essence, is composed of 64-bit extensions to IA-32, i.e., it’s a superset of the x86 instruction set. Such instruction set is referred to as AMD64 (initially, x86-64.) Later, Intel cloned it under the name Intel 64. AMD’s processors Athlon 64, Terium, Opteron, Sempron, etc., are based on AMD64.
    Opcode: An opcode (operation code) is the part of a machine language instruction (pure binary code) specifying the operation to be performed. The other portion of the instruction is the operand, which is optional and represents the data to be operated on. In assembly language, mnemonics are used to represent the opcodes. Concretely, and according to the IASDM, a mnemonic is a reserved name for a class of instruction opcodes which have the same function. For example, in JMP 114, the mnemonic is JMP, and the operand is 114 (remember, 114 in hexadecimal, which is 276 in decimal.)

Continue reading “Encoding Intel x86/IA-32 Assembler Instructions”

Web, Evolution and Trust

By chance, I arrived to an old and interesting BBC news report (2008), Warning sounded on web’s future, on the worries of Tim Berners-Lee about the spreading of disinformation using the web. Such worries are still totally valid today. The article also touches on other related topics such as extending the reach of the web and improving the web’s usability.

Regarding the problem of publishing insincere or unfounded information on the web, Berners-Lee cited the campaign started because of the activation of the Large Hadron Collider. Specifically, some groups used the web for communicate invalid beliefs about the world being destroyed by effect of the LHC. This use of the web is, in first instance, unethical. Further, it may transmit fears, and additionally, the information posted by such groups has no scientific grounds. This a typical example of misusing a system.

Purple spider web

(Photo by toccia). This kind of problem arises because of the web’s intrinsic nature. The web is a different system… a system which is now inevitably linked to the behavior and trends of human society. The web is an open and complex system. It’s open because we can add as much information as we want, and it’s complex because it’s composed of a huge amount of producers and consumers of information, and their interactions. There is other factor that shapes the web complexity: evolution

The web changes at very high rates. The web’s technologies an content change so quickly, that it’s impossible for any person to assimilate all this evolution. After all, the user only wants to open her browser and read the news. Typically, she is interested neither in the technical details behind the publishing platform, nor in the path followed by the information until arriving to the final form on the online media. There is a tool the user recurs to in order to fight complexity: trust.
Continue reading “Web, Evolution and Trust”

White Rabbit

Previously, a song for a dark mood. Later, a sexy one. Now, it’s time for some psychedelic tunes, with the gorgeous Grace Slick. “White Rabbit” belongs to Surrealistic Pillow (1967), the second album by Jefferson Airplane. Besides being one of the essential rock albums, “Surrealistic Pillow” meant the debut of Slick as vocalist of JA on studio records.

By the way, covers of “White Rabbit” by Patti Smith and by Grace Potter and The Nocturnals are very good.

Postales en Sepia: II

No la amo, es sólo que me gusta escucharla todas las horas que ella quiera. Tampoco es que me parezca linda, pero me siento cómodo en su cintura. Es decir, el problema es mío, y por suerte, ella no se entera. Me duele la garganta si no quiebro el silencio con su nombre. Ya no siento la piel si no es con sus besos clandestinos y apresurados (a veces, torpes). Pero no se lo cuentes, porque entonces ya no podré hacer que se sienta vacía cuando le digo: “Es sólo un juego”.

Postal anterior

Programmers from the Wild West

Analysis, Design, and related topics are for sissies, and for allowing professors of Computer Science who are bad at mathematics to make a living. SDLC is a pony. Cowboys ride horses.

We all know what happens when a project’s deadline is not met. Besides firing someone, hard, dry heroes appear. Lonesome, ruthless and distrustful heroes which brings the peace only revolvers can conquer. Sometimes, the guys with the money hire them as the ultimate saviors: they have bothered to come here, from the farthest west, to rescue the project. They are irresistible: they are the cowboy programmers. It’s men’s time.

Ben Cartwright & Sons
Ben Cartwright & Sons

Continue reading “Programmers from the Wild West”

Imparcialidad

En las semanas previas Rudyard Kipling ha estado presente en mis lecturas. Primero con Kim y luego con The Phantom Rickshaw. Cuando comenté sobre el cuento, destaqué el humor que mostraba. En relación con el humor en la literatura, hoy me he reencontrado con una oración de mi autor favorito, en su cuento “La Señora Mayor”, incluido en El Informe de Brodie:

Siempre envidiosos de nuestras glorias, los venezolanos atribuyeron esta victoria al general Simón Bolívar, pero el observador imparcial, el historiador argentino, no se deja embaucar y sabe muy bien que sus laureles corresponden al coronel Mariano Rubio.

En ningún momento tengo dudas sobre la imparcialidad alegada allí 😀

Por cierto que el prólogo de El Informe de Brodie inicia con una referencia a Kipling. Dice Borges:

Los últimos relatos de Kipling fueron no menos laberínticos y angustiosos que los de Kafka o los de James, a los que sin duda superan; pero en 1885, en Lahore, había emprendido una serie de cuentos breves, escritos de manera directa, que reuniría en 1890. No pocos – “In the House of Suddhoo”, “Beyond the Pale”, “The Gate of the Hundred Sorrows” – son lacónicas obras maestras; alguna vez pensé que lo que ha concebido y ejecutado un muchacho genial puede ser imitado sin inmodestia por un hombre en los lindes de la vejez, que conoce el oficio. El fruto de esa reflexión es este volumen, que mis lectores juzgarán.

Kim precisamente vive en Lahore, y es allí donde acontece su encuentro con el lama tibetano, evento que desencadena su aventura a través de la India colonial. Me encanta establecer estas conexiones literarias.

Debugging “hello, world”

The Go command (g) will run the program starting at the given address (in this case, CS:0100) If everything goes right, the program should output the intended “hello, world!” string, and finish with the message “Program terminated normally.”

Yesterday, we took a break after long hours of intensive coding, and a coworker started establishing similarities between our current frantic coding and the (fortunately) gone days of college homework. I specifically recalled a project I had to build by using MS-DEBUG: a simple calculator in assembly, which also required the hassle of dealing with pretty and safe user input. I have no intention of looking for such listings, but I thought about revisiting, for a moment, the old and dear friend MS-DEBUG 🙂 I’ll harness a previous post in this blog, and try to build a little ‘hello, world’ program in MS-DEBUG. I know this has little value outside a personal feeling and a tad of nostalgia, maybe.

I remember that a 100 tells DEBUG to accept code in memory starting out from CS:0100. Ok.

Now comes the data, which here simply consist of the string 'hello, world!'. A neat output, however, would require newlines before and after our intended string. A newline is comprised of a carriage return (CR = ASCII 13) and a line feed (LF = ASCII 10) on the display. As DEBUG only understand hexadecimal numbers, we must use 0Dh and 0Ah for CR and LF, respectively. Except in code, we will represent hexadecimal numbers by following the value with ‘h’.) Fortunately, DEBUG also admits ASCII characters directly (and the pseudo-instructions DB and DW!), so we can express our complete string as

db 0d,0a,"hello, world!",0d,0a,"$"

Continue reading “Debugging “hello, world””

A Review of OpenGL Programming on Mac OS X

All of the explanations are crystal clear, focused into the concepts and techniques OpenGL developers really need. The book comprises OpenGL architecture and configuration on OS X, and the various APIs we can use in order to create OpenGL applications, specifically, CGL, AGL, Cocoa, (our old buddy) GLUT, and X11 APIs.

OpenGL Programming on Mac OS X

The full title of this book is “OpenGL Programming on Mac OS X: Architecture, Performance and Integration.” Its fortunate authors are Robert P. Kuehne and J. D. Sullivan, two professionals who thoroughly know what they are talking about. Moreover, the book has been published by one of my favorites, Addison-Wesley. Therefore, success in conveying the details of OpenGL Programming on the Apple platform seems guaranteed. After reading it, I confirmed that any graphics programmer will learn a lot of things from this book. And nowadays, with a market saturated by rushed books, it’s a bliss.
Continue reading “A Review of OpenGL Programming on Mac OS X”