asm-x86 Reference
Notation
| Operand |
r | register ( EAX , EBX , ... etc.) |
m | memory address |
r/m | register reference or memory reference |
s | segment register |
i | index register |
disp | displacement |
opc | opcode |
a | address |
? | various types |
Registers
Register names for the 32-bit, 16-bit, and byte register operands recognized by
asm-x86 are listed below.
EAX | AX | AL | AH |
EBX | BX | BL | BH |
ECX | CX | CL | CH |
EDX | DX | DL | DH |
EBP | BP | | |
ESP | SP | | |
ESI | SI | | |
EDI | DI | | |
Indirect Addressing
[BX+SI] ( disp -- n )
[BX+DI] ( disp -- n )
[BP+SI] ( disp -- n )
[BP+DI] ( disp -- n )
[SI] ( disp -- n )
[DI] ( disp -- n )
[BP] ( disp -- n )
[BX] ( disp -- n )
[EAX] ( disp -- n )
[EBX] ( disp -- n )
[ECX] ( disp -- n )
[EDX] ( disp -- n )
[EBP] ( disp -- n )
[ESP] ( disp -- n )
[ESI] ( disp -- n )
[EDI] ( disp -- n )
Branching
IF, ( opc -- a)
ELSE, ( a1 -- a2)
THEN, ( a -- )
BEGIN, ( -- a)
UNTIL, ( a opc -- )
AGAIN, ( a -- )
WHILE, ( a1 opc -- a2 a1)
REPEAT, ( a a -- )
DO, ( -- ) Define code position for LOOP,
LOOP, ( -- ) Loop (decrement ECX; loop if not zero)
LOOPZ, ( -- ) Loop (decrement ECX; loop if not zero and ZF=1)
LOOPNZ, ( -- ) Loop (decrement ECX; loop if not zero and ZF=0)
LEAVE, ( -- ) High level procedure exit
JMP, ( ? -- ) Jump
LJMP, ( a -- )
JMP-FROM ( -- )
JMP-TO ( -- )
CALL, ( ? -- ) Call machine code procedure
RET, ( -- ) Return from procedure
RETF, ( -- )
IRET, ( -- ) Return from interrupt
LABEL: ( -- ) Define code position for JMP,
LABEL' ( -- )
Arithmetic and Logic Instructions
ADD, ( ? -- ) Add
ADC, ( ? -- ) Add with carry
SUB, ( ? -- ) Subtract
SBB, ( ? -- ) Subtract with borrow
INC, ( r | r/m -- ) Increment by 1
DEC, ( r | r/m -- ) Decrement by 1
MUL, ( -- ) Unsigned multiply
IMUL, ( -- ) Signed multiply
DIV, ( -- ) Unsigned divide
IDIV, ( -- ) Signed divide
NEG, ( -- ) Two's complement negation
CLC, ( -- ) Clear carry flag
STC, ( -- ) Set carry flag
CMC, ( -- ) Complement carry flag
AND, ( ? -- ) Bitwise AND
OR, ( ? -- ) Bitwise OR
XOR, ( ? -- ) Bitwise exclusive OR
CMP, ( ? -- ) Compare two operands
COM, ( -- )
TEST, ( ? -- ) Logical compare using AND
Rotate and Shift Instructions
These instructions can have one or two operands.
To shift by CL, omit the first operand
SHL, ( n r/m | r/m -- ) Shift left by n bits
SHR, ( n r/m | r/m -- ) Shift right by n bits
SAR, ( n r/m | r/m -- ) Signed divide by 2, n or CL times
ROL, ( n r/m | r/m -- ) Rotate left by n or CL bits
ROR, ( n r/m | r/m -- ) Rotate right by n or CL bits
RCL, ( n r/m | r/m -- ) Rotate left using carry flag
RCR, ( n r/m | r/m -- ) Rotate right using carry flag
Memory and String Instructions
MOV, ( r/m/i r/m -- ) Move data
MOVZX, ( r/m r -- ) Move with zero-extend
MOVSX, ( r/m r -- ) Move with sign-extend
LEA, ( -- ) Load effective address
LES, ( -- )
LDS, ( -- )
XCHG, ( r m | m r | r1 r2 -- ) Exchange register/memory with register
PUSH, ( r | s | r/m -- ) Push operand onto the machine stack
POP, ( r | s | r/m -- ) Pop a word/dword from the machine stack
CMPS, ( r -- ) Compare string operands
LODS, ( r -- ) Load string
MOVS, ( r -- ) Move string
SCAS, ( r -- ) Scan string
STOS, ( r -- ) Store string
CLD, ( -- ) Clear direction flag
STD, ( -- ) Set direction flag
I/O, Interrupts, and Other Instructions
IN, ( n r | r -- ) Input from port
OUT, ( n r | r -- ) Output to port
INT, ( n -- ) Call to interrupt procedure
CLI, ( -- ) Clear interrupt flag (disable external interrupts)
STI, ( -- ) Set interrupt flag (resume external interrupts)
HLT, ( -- ) Halt the processor
WAIT, ( -- ) Wait until BUSY# pin is inactive (HI)
LOCK: ( -- )
SAHF, ( -- ) Store AH register into Flags
LAHF, ( -- ) Load Flags into AH register
NOP, ( -- ) No operation
Miscellaneous
DAA, ( -- )
DAS, ( -- )
AAA, ( -- )
AAS, ( -- )
AAM, ( -- )
AAD, ( -- )
CBW, ( -- ) Convert signed byte to signed word
CDW, ( -- ) Convert signed word to signed doubleword
CWDE, ( -- ) Convert signed word to signed doubleword
PUSHAD, ( -- )
POPAD, ( -- )
PUSHFD, ( -- )
POPFD, ( -- )
INT3, ( -- )
INTO, ( -- )
XLAT, ( -- ) Table lookup translation
Floating Point Unit Instructions
FLD, ( st | m -- )
FST, ( st | m -- )
FSTP, ( st | m -- )
FADD, ( st | r/m -- )
FSUB, ( st | r/m -- )
FMUL, ( st | r/m -- )
FDIV, ( st | r/m -- )
FDIVR, ( st | r/m -- )
FSUBR, ( st | r/m -- )
FCOM, ( st | r/m -- )
FCOMP, ( st | r/m -- )
FADDP, ( -- ) st(1) = st(1) + st(0), pop
FMULP, ( -- ) st(1) = st(1) * st(0), pop
FSUBP, ( -- ) st(1) = st(1) - st(0), pop
FSUBRP, ( -- ) st(1) = st(0) - st(1), pop
FDIVP, ( -- ) st(1) = st(1) / st(0), pop
FDIVRP, ( -- ) st(1) = st(0) / st(1), pop
FILD, ( m -- ) push, load integer from memory into st(0)
FIST, ( m -- ) store integer in st(0) to memory
FISTP, ( m -- ) store integer in st(0) to memory, pop
FIDIV, ( m -- )
FIDIVR, ( m -- )
FIMUL, ( m -- )
FIADD, ( m -- )
FISUB, ( m -- )
FISUBR, ( m -- )
FCHS, ( -- )
FABS, ( -- )
FTST, ( -- )
FLDZ, ( -- )
FLD1, ( -- )
FLDPI, ( -- )
FLDLG2, ( -- )
FLDL2T, ( -- )
FLDLN2, ( -- )
FLDL2E, ( -- )
F2XM1, ( -- )
FXTRACT, ( -- )
FPREM, ( -- )
FRNDINT, ( -- )
FXAM, ( -- )
FYL2X, ( -- )
FPREM1, ( -- )
FYL2XP1, ( -- )
FSCALE, ( -- )
FSIN, ( -- )
FCOS, ( -- )
FSINCOS, ( -- )
FPTAN, ( -- )
FPATAN, ( -- )
FDECSTP, ( -- )
FSQRT, ( -- )
FINCSTP, ( -- )
FCOMPP, ( -- ) compare st(0) and st(1), pop both
FUCOMPP, ( -- ) unordered compare of st(0) and st(1), pop both
FUCOM, ( st -- ) unordered compare of st(0) and st
FFREE, ( st -- )
FXCH, ( st -- ) exchange st(0) and st
FBLD, ( m -- ) load BCD encoded fp value
FBSTP, ( m -- ) save st(0) in BCD format, pop
FNOP, ( -- )
FWAIT, ( -- ) wait for fpu ready
FINIT, ( -- ) initialize fpu
FNCLEX, ( -- ) clear exceptions
FCLEX, ( -- ) clear exceptions with wait
FNSTCW, ( m -- ) save control word
FSTCW, ( m -- ) save control word with wait
FLDCW, ( m -- ) load control word
FNSTENV, ( m -- ) save environment
FSTENV, ( m -- ) save enironment with wait
FLDENV, ( m -- ) load environment
FNSTSW, ( r/m -- ) save status word
FSTSW, ( r/m -- ) save status word with wait
FSAVE, ( m -- ) save fpu state
FRSTOR, ( m -- ) restore fpu state
Copyright © 2007 Creative Consulting for Research and Education