Saved searches

Use saved searches to filter your results more quickly

Cancel Create saved search Sign up Reseting focus

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Complete 8086 instruction set documentation.

Notifications You must be signed in to change notification settings

michaelsergio/nasm-instruction-set

This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Go to file

Folders and files

Last commit message Last commit date

Latest commit

History

View all files

Repository files navigation

Complete 8086 instruction set

Quick reference:

a b c d e f g h
AAA DAA HLT JNL LODSB POP ROR XCHG
AAD DAS IMUL JNLE LODSW POPA SAHF XLATB
AAM DEC INC JNO LOOP POPF SAL XOR
AAS DIV INTO JNP LOOPE PUSH SAR
ADC IDIV JA JNS LOOPNE PUSHA SBB
ADD IN JB JNZ LOOPNZ PUSHF SCASB
AND INT JBE JO LOOPZ RCL SCASW
CALL IRET JE JP MOV RCR SHL
CBW JAE JGE JPE MOVSB REP SHR
CLD JC JLE JPO MOVSW REPE STC
CLI JCXZ JNA JS MUL REPNE STD
CMC JG JNB JZ NEG REPNZ STI
CMP JL JNC LAHF NOP REPZ STOSB
CMPSB JMP JNE LDS NOT RET STOSW
CMPSW JNAE JNG LEA OR RETF SUB
CWD JNBE JNGE LES OUT ROL TEST

Operand types:

REG: AX, BX, CX, DX, AH, AL, BL, BH, CH, CL, DH, DL, DI, SI, BP, SP. SREG: DS, ES, SS, and only as second operand: CS. memory: [BX], [BX+SI+7], variable, etc. immediate: 5, -24, 3Fh, 10001101b, etc.

Notes:

AL, DL DX, AX m1 DB ? AL, m1 m2 DW ? AX, m2 
memory, immediate REG, immediate memory, REG REG, SREG 
include 'emu8086.inc' ORG 100h MOV AL, 1 MOV BL, 2 PRINTN 'Hello World!' ; macro. MOV CL, 3 PRINTN 'Welcome!' ; macro. RET

These marks are used to show the state of the flags:

Some instructions generate exactly the same machine code, so disassembler may have a problem decoding to your original code. This is especially important for Conditional Jump instructions.

Instructions in alphabetical order:

Instruction Operands Description

AAA

ASCII Adjust after Addition.

Corrects result in AH and AL after addition when working with BCD values. It works according to the following

if low nibble of AL > 9 or AF = 1 then:

MOV AX, 15 ; AH = 00, AL = 0Fh AAA ; AH = 01, AL = 05 RET
C Z S O P A r ? ? ? ? r 

AAD

ASCII Adjust before Division. Prepares two BCD values for division.

MOV AX, 0105h ; AH = 01, AL = 05 AAD ; AH = 00, AL = 0Fh (15) RET
C Z S O P A ? r r ? r ? 

AAM

ASCII Adjust after Multiplication.

Corrects the result of multiplication of two BCD values.

MOV AL, 15 ; AL = 0Fh AAM ; AH = 01, AL = 05 RET
C Z S O P A ? r r ? r ? 

AAS

ASCII Adjust after Subtraction.

Corrects result in AH and AL after subtraction when working with BCD values.

if low nibble of AL > 9 or AF = 1 then:

MOV AX, 02FFh ; AH = 02, AL = 0FFh AAS ; AH = 01, AL = 09 RET
C Z S O P A r ? ? ? ? r 

ADC

operand1 = operand1 + operand2 + CF

STC ; set CF = 1 MOV AL, 5 ; AL = 5 ADC AL, 1 ; AL = 7 RET
C Z S O P A r r r r r r 

ADD

operand1 = operand1 + operand2

MOV AL, 5 ; AL = 5 ADD AL, -3 ; AL = 2 RET
C Z S O P A r r r r r r 

AND

Logical AND between all bits of two operands. Result is stored in operand1.

These rules apply:

MOV AL, 'a' ; AL = 01100001b AND AL, 11011111b ; AL = 01000001b ('A') RET
C Z S O P 0 r r 0 r 

CALL

Transfers control to procedure, return address is (IP) is pushed to stack.

4-byte address may be entered in this form: 1234h:5678h, first value is a segment second value is an offset (this is a far call, so CS is also pushed to stack).

ORG 100h ; for COM file. CALL p1 ADD AX, 1 RET ; return to OS. p1 PROC ; procedure declaration. MOV AX, 1234h RET ; return to caller. p1 ENDP
C Z S O P A unchanged 

CBW

Convert byte into word.

if high bit of AL = 1 then:

MOV AX, 0 ; AH = 0, AL = 0 MOV AL, -5 ; AX = 000FBh (251) CBW ; AX = 0FFFBh (-5) RET
C Z S O P A unchanged