I am reading a textbook entitled Introduction to 80x86 Assembly Language and Computer Architecture by Richard C. Detmer
I have a question about immediate to memory mov
opcode. Here the portion of text I am referring too:
Continuing down figure 4.1, the next row is for immediate-to-memory moves. Each of these instructions has opcode
C6
, a ModR/M byte, additional address bytes (if needed), and finally a byte containing the immediate operand. The address is encoded as described above for memory-to-register moves. If, for example,smallCounter
references a byte in memory and the instructionmov smallCounter, 100
is assembled, the assembler will generate 7 (3+4) bytes of object code,C6 05 xx xx xx xx 64
, wherexx xx xx xx
represents the address in memory, and 64 is the byte-size hex version of 100. The ModR/M byte 05 is00 000 101
, Mod=00 and R/M=101 for direct memory addressing with the Reg field not needed and set to 000.As another example, consider
mov BYTE PTR [edx], -1
with the memory destination using register indirect mode. The opcode is still C6 and the immediate byte (which always comes last) is now FF for -1. The second byte is the ModR/M byte with Mod=00 for register indirect, Reg=000 (unused), and R/M=010 for EDX, making00 000 010
or 02. The object code is there forC6 02 FF
.page 92, chapter 4, section 1 - Copying Data
Figure 4.1 - entitled mov instructions with byte destination- is a chart with four columns:
- the first listing the destination
- the second listing the source
- the third listing the Opcode
- and the fourth listing the Bytes of Object code
The line in the chart the above portion is referring too is:
Destination: memory byte Source: immediate byte Opcode: C6 Bytes of Object Code: 3+
Forgive me for putting all that, but I wish for you and I to be on the same page for what my book is saying. I understand the part with the smallCounter but what perplexes me, is that the object code for the mov BYTE PTR [edx], -1
is without an address in memory. It is in indirect mode, so edx is taking the place as a pointer, so why doesn't the object code contain the address in memory it is pointing too? Is that only for variables like with smallCounter's opcode having an address? Why is overall the opcode the way it is for smallCounter in comparison with the other statement?