The asm51 8051 Assembler accepts all the assembly language instruction mnemonics defined for the 8051 by Intel. The mnemonics are listed in the table below. The addressing modes used with the instructions and the meaning and use of the Condition Codes are identical to the corresponding Intel features.
Mnemonic | Operation |
acall | Absolute subroutine call |
add | Add into Accumulator |
addc | Add with carry into Accumulator |
ajmp | Absolute jump |
anl |
AND register, direct byte, indirect RAM or immediate data to Accumulator AND Acc. or immediate data to direct byte AND direct bit to Carry AND complement of direct bit to Carry |
call | Generic call |
cjne |
Compare direct byte, or immediate data to Accumulator and jump if not equal Compare immediate data to register and jump if not equal Compare immediate to indirect and jump if not equal |
clr |
Clear Accumulator Clear Carry Clear direct bit |
cpl |
Complement Accumulator Complement Carry or direct bit |
da | Decimal addition adjust |
dec | Decrement |
djnz | Decrement and jump if not zero |
div | Divide |
inc | Increment |
jb | Jump if direct bit is set |
jbc | Jump if direct bit set and clear bit |
jc | Jump if Carry set |
jmp | Jump indirect |
jmp | Generic jump |
jnb | Jump if direct bit is NOT set |
jnc | Jump if Carry not set |
jnz | Jump if Accumulator is not zero |
jz | Jump if Accumulator is zero |
lcall | Long subroutine call |
ljmp | Long jump |
mov |
Move register, direct byte, indirect RAM or immediate data to Accumulator. Move Acc, immediate data or direct byte to register. Move Acc. register, direct byte, indirect RAM or immediate data to direct byte. Move Acc. direct byte or immediate data to indirect RAM. Load Data pointer with a 16-bit constant. Move direct bit to Carry. Move Carry to direct bit. |
movc | Move code byte to Accumulator |
movx | Move External RAM to Accumulator or vice versa |
mul | Multiply |
nop | No operation |
orl |
OR register, direct byte, indirect RAM or immediate data to Accumulator. OR Accumulator to direct byte. OR immediate data to direct byte. OR direct bit to Carry. OR complement of direct bit to Carry. |
push | Push direct byte onto stack |
pop | Pop direct byte from stack |
rl | Rotate Accumulator left |
rlc | Rotate Accumulator left through carry |
rr | Rotate Accumulator right |
rrc | Rotate Accumulator right through carry |
ret | Return from subroutine |
reti | Return from interrupt |
setb | Set Carry or direct bit |
sjmp | Short jump |
subb | Subtract from Accumulator with borrow |
swap | Swap nibbles within the Accumulator |
xch | Exchange with Accumulator |
xchd | Exchange low-order Digit indirect with Accumulator |
xrl |
Exclusive-OR direct byte, indirect RAM, immediate data to Accumulator. Exclusive-OR Accumulator to direct byte. Exclusive-OR immediate data to direct byte |
Table 8-1: Instruction set
The 8051 assembler recognizes generic jump and call instructions. The call instruction is translated to an acall or lcall instruction, dependent on the address of the operand. The
jmp instruction is translated to an ajmp, ljmp, or sjmp instruction.
In most cases, the assembler selects the shortest possible instruction, but with for instance external references in the address expression, the assembler has to generate an instruction with a 16 bit address. When it is known beforehand, that a short instruction will suffice, it is always possible to use this instruction instead of the generic version. If it turns out during linkage that an offset/address doesn't fit, the linker will give a warning message.