CS II-Program 10

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Program 10:

Aim: Write a program that seperates the two nibbles of a number stored in 2060 and stores the
same in memory location 2061 and 2062. The program must also multiply the nibbles and store
the result in 2063.

Algorithm:
1. Initialize product with zero and accumulator with memory location 2060.
2. Separate the two nibbles of a number and store it in Nib1 and Nib2.
3. Assign Nib1 and Nib2 to memory location 2061 and 2062.
4. Repeat the step till Nib 2 =0
5. a) Add Nib 1 value with product.
b) Decrement Nib2 by one.
6. Store the product of 2 Nib’s in memory location 2063.
7. Stop program execution.
Flowchart:
PROGRAM 12
Mnemonics
Address Label Opcode Operand Hexacode Comment
2000 START LXI H, 2060 21 Initialize HL with 2060
2001 60 Lower address byte
2002 20 Upper address byte
Move memory data to
2003 MOV A, M 7E Accumulator

2004 MOV B, M 46 Move memory data to B register


And immediate accumulatore
2005 ANI 0F H E6 data with 0F
2006 0F _
2007 INX H 23 Increament HL by 1
Move Accumulator data to C
2008 MOV C, A 4F register

2009 MOV A, B 78 Move B register data to A register


200A RLC 07 Rotate left content A register
200B RLC 07 Rotate left content A register
200C RLC 07 Rotate left content A register
200D RLC 07 Rotate left content A register
And immediate accumulatore
200E ANI 0F E6 data with 0F
200F 0F
2010 INX H 23 Increament HL by 1
move accumulator data to
2011 MOV M, A 77 memory

2012 XRA A, M AF Exclusive OR to Accumulator data

2013 S1 ADD M 86 Add memory data to accumulator


2014 DCR C 0D decreament C register by 1
Jump to label S1 if C register is
2015 JNZ 2014 C2 not zero
2016 14 Lower address byte
2017 20 Upper address byte
2018 INX H 23 Increament HL by 1
Move Accumulator data to
2019 MOV M, A 77 memory
201A STOP RST 1 CF Stop program execution
OUTPUT
Before execution After Execution
Memory Memory
loaction Data loaction Data
2060 62 2060 62
2061 02
2062 06
2063 0C

You might also like