0% found this document useful (0 votes)
8 views

CS II-Program 5

Uploaded by

spamacc938
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

CS II-Program 5

Uploaded by

spamacc938
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Program 5:

Aim: Write a program that multiply two 1 byte hexadecimal number stored in consecutive
memory location starting from 2030H. Store the two byte result in consecutive memory location
starting from 2032 beginning with lower order byte.

Algorithm:

1. Initialize HL pointer to initial product zero.


2. Initialize accumulator with first value N1.
3. Move the accumulator content to E and move N2 to accumulator.
4. Set D=0 and start the loop and continue till N1 becomes zero.
5. Store the result in memory location 2032 and 2033H.

Flowchart:
Program:

Mnemonics
Address Label Opcode Operand Hexacode Comment
2000 START CXI H, 0000 21 Set initial product to 0
2001 00 _
2002 00 _
2003 CDA 2030H 3A set A=N1
2004 30 Lower address byte
2005 20 Upper address byte
2006 MOV E, A 5F Set E = N1
2007 CDA 2031H 3A Set A = N2
2008 31 Lower address byte
2009 20 Upper address byte
200A MVI D,00H 16 Set D=00
200B 00 _
200C LOOP DAD D 19 Product= Product + N1
200D DCR A 3D N2=N2 - 1
200E JNZ LOOP C2 Repeat if N2 ≠ 0
200F 0C Lower address byte
2010 20 Upper address byte
2011 SHLD 2032H 22 store value of HL to memory location
2012 32 Lower address byte
2013 20 Upper address byte
2014 STOP RST 1 CF Stop Program execution
Output:

Befor Execution After Execution


Memory Memory
location Data location Data
2030 09 2030 09
2031 05 2031 05
2032 _ 2032 2D
2033 _ 2033 0

You might also like