开发者

Hex values of registers? x86

MOV DL,AL

"MOV DL" = B2

But what is the hex byte value for A开发者_JS百科L? Where are these listed?

I just realized it must be another opcode! Can anyone point me in the right direction?


From the Intel Architecture Software Developer's Manual, Volume 2: Instruction Set Reference Manual, Table 3-1. Register Encodings Associated with the +rb, +rw, and +rd Nomenclature, page 3-3:

AL = 0 AX = 0 EAX = 0
CL = 1 CX = 1 ECX = 1
DL = 2 DX = 2 EDX = 2
BL = 3 BX = 3 EBX = 3
AH = 4 SP = 4 ESP = 4
CH = 5 BP = 5 EBP = 5
DH = 6 SI = 6 ESI = 6
BH = 7 DI = 7 EDI = 7

To answer your question ("aha great. I'm having a hard time finding the a list of instructions to move registers into registers. Can you shed any light?"):

First here are some fish: (for 8-bit regs)

8a c0        mov     al, al
8a c1        mov     al, cl
8a c2        mov     al, dl
8a c3        mov     al, bl
8a c8        mov     cl, al
8a c9        mov     cl, cl
8a ca        mov     cl, dl
8a cb        mov     cl, bl
8a d0        mov     dl, al
8a d1        mov     dl, cl
8a d2        mov     dl, dl
8a d3        mov     dl, bl
8a d8        mov     bl, al
8a d9        mov     bl, cl
8a da        mov     bl, dl
8a db        mov     bl, bl

And here's how to get started fishing:

In the intel instruction set manual, look up the MOV instruction, in page 3-402. You will find a table listing various flavors of the MOV instruction, starting with:

88 /r MOV r/m8,r8 Move r8 to r/m8
89 /r MOV r/m16,r16 Move r16 to r/m16
89 /r MOV r/m32,r32 Move r32 to r/m32
8A /r MOV r8,r/m8 Move r/m8 to r8
8B /r MOV r16,r/m16 Move r/m16 to r16
8B /r MOV r32,r/m32 Move r/m32 to r32

Note how our fish above use the 8A opcode. As you may guess, r8 is an 8-bit register, and r/m8 can be either an 8-bit register or a byte from memory. Also note how different MOV opcodes are available for 16- and 32-bit registers and values (r16, r32). Pages 3-2 to 3-5 explain the various types of arguments you can specify on a MOV instruction.

But, you may say, this doesn't tell you enough about how to construct the following bytes in the instruction. For that, look at section 2.1 - General Instruction Format, starting at page 2-1. x86 instructions may be composed of up to 6 byte sequences: prefixes, opcode, ModR/M, SIB, displacement and immediate values. Our register move instructions are simple, and include only an opcode (8A) and a ModR/M byte.

The breakdown of the ModR/M byte is documented in section 2.4, and in all-encompassing tables in pages 2-5 to 2-6. The you will find that the ModR/M byte can encode both the source and destination register. For example, to move from AL to DL you will use the D0 ModR/M value, giving the 8A D0 instruction.


Read "Intel® 64 and IA-32 Architectures Software Developer’s Manual Volume 2A: Instruction Set Reference, A-M"


You find all the opcodes in some nice tables for x86 at http://www.sandpile.org

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜