8086 assembler tutorial for beginners (part 6)

Arithmetic and Logic Instructions

Most Arithmetic and Logic Instructions affect the processor status register (or Flags)



As you may see there are 16 bits in this register, each bit is called a flag and can take a value of 1 or 0.



There are 3 groups of instructions.



First group: ADD, SUB,CMP, AND, TEST, OR, XOR

These types of operands are supported:

REG, memory
memory, REG
REG, REG
memory, immediate
REG, immediate
REG: AX, BX, CX, DX, AH, AL, BL, BH, CH, CL, DH, DL, DI, SI, BP, SP.

memory: [BX], [BX+SI+7], variable, etc...

immediate: 5, -24, 3Fh, 10001101b, etc...

After operation between operands, result is always stored in first operand. CMP and TEST instructions affect flags only and do not store a result (these instruction are used to make decisions during program execution).

These instructions affect these flags only:
       CF, ZF, SF, OF, PF, AF.



Second group: MUL, IMUL, DIV, IDIV

These types of operands are supported:

REG
memory
REG: AX, BX, CX, DX, AH, AL, BL, BH, CH, CL, DH, DL, DI, SI, BP, SP.

memory: [BX], [BX+SI+7], variable, etc...

MUL and IMUL instructions affect these flags only:
       CF, OF
When result is over operand size these flags are set to 1, when result fits in operand size these flags are set to 0.

For DIV and IDIV flags are undefined.



Third group: INC, DEC, NOT, NEG

These types of operands are supported:

REG
memory
REG: AX, BX, CX, DX, AH, AL, BL, BH, CH, CL, DH, DL, DI, SI, BP, SP.

memory: [BX], [BX+SI+7], variable, etc...

INC, DEC instructions affect these flags only:
       ZF, SF, OF, PF, AF.

NOT instruction does not affect any flags!

NEG instruction affects these flags only:
       CF, ZF, SF, OF, PF, AF.






<<< previous part <<<      >>> Next Part >>>