Вы находитесь на странице: 1из 4

Aman Arora

06496502714

EXPERIMENT 4

AIM

Write a program to subtract two 16-bit numbers, the first number is in memory location 2501H, the second number is
in memory location 2503H, 2504H and the result is to be stored in memory location 2506H, 2505H and 2507H.

PROGRAM

Memory Location Machine Code Mnemonics Operands Comments

2000H 2A, 01, 25 LHLD 2501H Get the first number


in HL pair.

2003H EB XCHG H-L Get the first number


in AL pair.

2004H 2A, 03, 25 LHLD 2503H Get the second


number in HL pair.
2007H 0E, 00 MVI C, 00H Make contents of C
register 00H.
2009H 19 DAD D Add two Numbers

200A H 02, 0E, 20 INC Next Jump if not carry to


label Next.
200D H 0C INR C If carry, increment
the content of C by 1.
200E H 22, 05, 25 Next 2505H Store the sum from
SHLD HL pair to memory
location to add
2505H and 2506H.
2011H 79 MOV A,C Move the carry from
accumulator to
register C.
2012H 32, 07, 25 STA 2507H Store the carry from
accumulator to
memory location
whose address is
2507H.
2015H 76 HLT Stop
Aman Arora
06496502714

STEPS

1. RESET
2. DELGO
3. REL EXMEM (2 times)
4. 2501 MEMC NEXT 01
5. 2502 MEMC NEXT 02
6. 2503 MEMC NEXT 22
7. 2504 MEMC NEXT 22
8. 2507 MEMC NEXT 00
9. FILL
10. REPEAT Steps 1-3
11. 2000 MEMC NEXT 2A
12. 2001 MEMC NEXT 01
13. 2002 MEMC NEXT 25
14. 2003 MEMC NEXT EB
15. 2004 MEMC NEXT 2A
16. 2005 MEMC NEXT 03
17. 2006 MEMC NEXT 25
18. 2007 MEMC NEXT 0E
19. 2008 MEMC NEXT 00
20. 2009 MEMC NEXT 19
21. 200A MEMC NEXT 02
22. 200B MEMC NEXT 0E
23. 200C MEMC NEXT 20
24. 200D MEMC NEXT 0C
25. 200E MEMC NEXT 22
26. 200F MEMC NEXT 05
27. 2010 MEMC NEXT 25
28. 2011 MEMC NEXT 79
29. 2012 MEMC NEXT 32
30. 2013 MEMC NEXT 07
31. 2014 MEMC NEXT 25
32. 2015 MEMC NEXT 76
33. FILL
34. DELGO 2000 FILL E (will be displayed)
35. REPEAT Steps 1-3
36. 2505 MEMC NEXT 23
37. 2506 MEMC NEXT 24
38. 2507 MEMC NEXT 21

Aman Arora
06496502714
RESULT

2505 23

2506 24

2507 21
START

GET THE FIRST NUMBER IN HL PAIR


GET THE SECOND NUMBER IN DE PAIR

ADD THE TWO NUMBERs

IF CARRY
N

YES

INCREMENT THE CONTENT OF C


REGISTER BY ONE

STORE THE RESULT

STOP

Вам также может понравиться