2. WRITE A PROGRAM TO SHIFT A NUMBER LEFT BY ONE
BIT
Memory address Labels Mnemonics, operands Comments
2000 LHLD 2501H Get 1st number in H-L pair
2003 DAD H Shift left by one bit
2004 SHLD 2503H Store result in 2503H & 2504H
2007 HLT Halt
Suppose 7596H is the number which will be shifted left by one
bit.
0111 0101 1001 0110
(7) (5) (9) (6)
3. WRITE A PROGRAM FOR 8 BIT DIVISION
DIVIDE 489B BY 1A
Memory address Labels Mnemonics, operands Comments
2000 LHLD 2501H Get dividend in H-L pair
2003 LDA 2503H Get divisor from 2503H
2006 MOV B,A Divisor in register B
2007 MVI C,08 Count=08 in register C
2009 LOOP DAD H Shift dividend and quotient left by one bit
200A MOV A,H MSBs of dividend in accumulator
200B SUB B Subtract divisor from MSBs of dividend
200C JC AHEAD Is MSB part of dividend>divisor? No, go to
AHEAD
200F MOV H,A MSBs of dividend in register H
2010 INR L Yes, add 1 to quotient
2011 AHEAD DCR C Decrement count
2012 JNZ LOOP Is count=0? No, jump to LOOP.
2015 SHLD 2504H Store quotient in 2504H and remainder in
2505H
2018 HLT
Example-1
2501-9BH, 2502-48H, 2503-1A H(Divisor)
Result is-
2504-F2H (Quotient), 2505-07(Remainder)