2. INSTRUCTION CLASSIFICATION
• Data Transfer group
• Arithmetic group
• Logical group
• Branch group
• Stack, I/O and Machine Control group
3. WRITE A PROGRAM TO SUBTRACT TWO 8 BIT
NUMBERS
Memory address Mnemonics, operands Comments
2000 LXI H,2501H Get address of 1st number in
H-L pair
2003 MOV A,M 1st number in accumulator
2004 INX H Content of H-L pair increases
from 2501H to 2502H
2005 SUB M 1st num-2nd num
2006 INX H Content of H-L pair becomes
2503H
2007 MOV M,A Store result in 2503H
2008 HLT Halt
Example-1 Example-2
2501-49H 2501-F8H
2502-32H 2502-9BH
Result is stored in the memory location 2503H
2503-17H 2503-5DH
Note: If the second
number is greater than
the first number, the
processor will give result
in 2’s complement, i.e.,
negative result.
4. BRANCH
GROUP
Categorized into two types: Conditional and Unconditional
Conditional branch instructions transfer the program to the specified address when certain condition is
satisfied.
Unconditional branch instructions transfer the program to the specified address unconditionally.
Unconditional Jump Instruction
JMP addr(label) jump to the instruction specified by the address T-states: 10 Flags:
none M-cycle-3
Byte 2nd and byte 3rd of the instruction give the address of the label (memory location)
where the program
jumps for next instruction to be executed.
5. JZ addr (label) Jump if result is zero T-states: 7/10 Flags affected: none M-cycle-2/3
The program jumps to the instruction specified by the address (label) if result is zero.
JNZ addr (label) Jump if result is not zero T-states: 7/10 Flags affected: none M-cycle-2/3
The program jumps to the instruction specified by the address (label) if result is not zero.
JC addr (label) Jump if there is carry T-states: 7/10 Flags affected: none M-cycle-2/3
The program jumps to the instruction specified by the address (label) if there is carry (i.e., CS=1)
JNC addr (label) Jump if there is no carry T-states: 7/10 Flags affected: none M-cycle-2/3
The program jumps to the instruction specified by the address (label) if there is no carry (i.e.,
CS=0)
JP addr (label) Jump if the result is plus T-states: 7/10 Flags affected: none M-cycle-2/3
The program jumps to the instruction specified by the address (label) if the result is plus.
JM addr (label) Jump if the result is minus T-states: 7/10 Flags affected: none M-cycle-2/3
The program jumps to the instruction specified by the address (label) if the result is minus.
JPE addr (label) Jump if even parity T-states: 7/10 Flags affected: none M-cycle-2/3
The program jumps to the instruction specified by the address (label) if even parity (i.e., P=1).
JPO addr (label) Jump if odd parity T-states: 7/10 Flags affected: none M-cycle-2/3
The program jumps to the instruction specified by the address (label) if odd parity (i.e., P=0).
BRANCH
GROUP
6. WRITE A PROGRAM TO ADD TWO 8 BIT NUMBERS
WHOSE RESULT WILL BE 16 BIT
Memory address Labels Mnemonics, operands Comments
2000 LXI H,2501H Get address of 1st number in H-L pair
2003 MVI C,00 MSBs of sum in register C,
Initial value=00
2005 MOV A,M 1st number in accumulator
2006 INX H Content of H-L pair increases from
2501H to 2502H
2007 ADD M 1st num+2nd num
2008 JNC AHEAD Is Carry? No, go to the label AHEAD
200B INR C Yes, increment C.
200C AHEAD STA 2503H Store LSBs of result in 2503H
200F MOV A,C Store MSBs of result in
accumulator
2010 STA 2504H Store MSBs of result in 2504H
2013 HLT
Example-1
2501-98H 2502-9AH
Result is stored in the memory location 2503H & 2504H
2503-32H, 2504-01H