You are on page 1of 3

Rajat Gupta

00996502714

EXPERIMENT 3

AIM

Write a program to subtract two 8-bit numbers, the first number is in memory location 5800H, the second number is in
memory location 5801H and the result is to be stored in memory location 5802H.

PROGRAM

Memory Location Machine Code Mnemonics Operands Comments

2000H 2A, 01, 25 LHLD 2501H Store the machine


code 3E at location
2000H and operand
08H at 2001H
2002H 06, 04 MVI B 04H Store the machine
code 06 at location
2002H and its
operand 04H at
2003H
2004H 90 SUB B Subtract the second
number from the first
number and store the
result in accumulator
2005H 32, 02, 58 STA 5802H Store the machine
code 32 at location
2005H and Low
order bit (02) and
Higher order bit (58)
at 2006H and 2007H
respectively
2008H 76 HLT Stop (End of
Program). Result
stored at 5802H
Rajat Gupta
00996502714

STEPS

1. RESET
2. DELGO
3. REL EXMEM (2 times)
4. 5800 MEMC NEXT 08
5. 5801 MEMC NEXT 04
6. 5802 MEMC NEXT 00
7. FILL
8. REPEAT Steps 1-3
9. 2000 MEMC NEXT 3E
10. 2001 MEMC NEXT 08
11. 2002 MEMC NEXT 06
12. 2003 MEMC NEXT 04
13. 2004 MEMC NEXT 90
14. 2005 MEMC NEXT 32
15. 2006 MEMC NEXT 02
16. 2007 MEMC NEXT 58
17. 2008 MEMC NEXT 76
18. FILL
19. DELGO 2000 FILL E (will be displayed)
20. REPEAT Steps 1-3
21. 5802 MEMC NEXT 04 (Result displayed)

RESULT

5802H 04
START

INITIALIZE THE REGISTER A WITH VALUE 08

INITIALIZE THE REGISTER B WITH VALUE 04

SUBTRACT THE NUMBERS AND STORE THE


RESULT IN ACCUMULATOR

STORE THE RESULT GIVEN BY


ACCUMULATOR IN MEMORY

STOP

You might also like