Question regarding assembly language
I am reading the book The Art of Assembly Language. I came across these two lines.
the three byte encoding for mov ax, [1000] would be 0C6h, 00h,
10h and the three byte encoding for mov ax, [2000] would be 0C6h, 00h, 20h.
Can anybody show me how mov ax, [1000] converted to oc6h, ooh, 10h and mov ax, [2000] converted to 0C6h, 00h, 20h. Can anybody show me the calculations? Thanks in advance.
EDIT: I am a starter in assembly programming, kindly explain wi开发者_运维知识库th description.
Just guessing, but looks to me like:
0C6h - This is the opcode for "mov ax,"
00h 10h - This is the address 1000h, Little Endian
00h 20h - This is the address 2000h, Little Endian
I'm assuming your confusion lies in the fact that 1000 was encoded as 10h.
ax is an alias for the bottom 16 bits of the 32 bit eax register. So mov ax, 1000 knows that this is a 16-bit operation. 1000 is encoded as 00 10 in memory because it was encoded using little-endianness which basically means that the most significant byte is last in physical order.
00h is the LoByte of the Memory Address
20h is the HiByte of the Memory Address
OC6h is the OpCode instruction for mov, ax
The opcodes for all x86 instructions can be found at http://download.intel.com/design/intarch/manuals/24319101.pdf (mov is at page 442). Chapter 2 describes how opcodes are encoded with register arguments.
Other answers already explain the encoding :-)
精彩评论