Experiment 7: Aim: To Find The 1's Complement of An 8-Bit Number. Flowchart
Experiment 7: Aim: To Find The 1's Complement of An 8-Bit Number. Flowchart
Start
Complement accumulator
Stop
Program:
Address Mnemonics Operand Opcode Remarks
0000 LDA 2500 3A Load H-L pair with data
from 2500H
0001 00 Lower order of 2500H
0002 25 Higher order of 2500H
0003 CMA 2F Complement
Accumulator
0004 STA 2501 32 Store the result at memory
location on 2501H
0005 01 Lower order of 2501H
0006 25 Higher order of 2501H
0007 HLT 76 Halt
Explanation:
1. This program finds the 1’s complement of 8-bit number
stored in memory location 2500H.
2. Let us assume that the operand stored at memory location
is 50H.
3. The operand is moved to accumulator from memory
location 2500H.
4. Then its complement is found by using CMA instruction.
5. The result is stored at memory location 2501H.
Output:
- Before execution
2500H: 50H
- After execution
2501H: AFH
Experiment 8
Aim: Program to find 2’s complement of an 8-bit
number.
Flowchart:
Start
Complement accumulator
Stop
Program:
Address Mnemonics Operand Opcode Remarks
0000 LDA 2500 3A Load H-L pair with data
from 2500H
0001 00
0002 25
0003 CMA 2F Complement Accumulator
0004 INR A 3C Increment Accumulator
0005 STA 2501 32 Share the result with
memory location 2501H
0006 01
0007 25
0008 HLT 76 Halt
Explanation:
1. This program finds the 2’s complement of 8-bit number
stored in memory location 2500H.
2. Let us assume that the operand stored at memory location
is 50H.
3. The operand is moved to accumulator from memory
location 2500H.
4. Then its complement is found by using CMA instruction.
5. One is added to accumulator by incrementing it is to find
its 2’s complement.
6. The result is stored at memory location 2501H.
Experiment 9
start
Add B with A
stop
Program:
Address Mnemonics operand opcode Remark
0000 LXI H , 4500H 21 Load H-L pair with
address 4500H
0001 00
0002 45
0003 MOV A,M 7E Move the first operand
from memory to
register A
Explanation:
1. The program adds two operands stored in memory
Location 4500H without considering the carry.
2. Let us assume that the operand stored at memory location
45004 is 08H and 4501H & 09H.
3. Initially H-L pair is loaded with the address of first memory
location.
4. The first operand is moved to accumulator from memory
location 4500H and H-L pair is incremented to next
memory location.
5. The second operand is moved from memory location
4501H to register B.
6. The two operand are added and the result are stored in
accumulator.
7. H-L pair is moved from the accumulator to memory
location 4502H.
Output:
- Before execution:
4500H:08H
4501H:01H
- After execution:
4502H:09H
Experiment 10
Aim: Program to multiply two 8-bit numbers.
Flowchart:
start
Add B with C
Decrement C
If
C=0
YES
Increment H-L pair
Move the result from accumulator to memory
stop
Experiment 11
Aim: Program to subtract two 8-bits number without
considering borrow.
Flowchart:
Start
Subtract B from A
Increment HL pair
Stop
Program:
Address Mnemonics Operand Opcode Remarks
0000 LXI H, 21 Load HL pair with address
4500H 4500H
0001 00
0002 45
0003 MOV A,M 7E Move the operand from
memory to register A
0004 INX +1 23 Increment HL pair
0005 MOV B,M 46 Move the 2nd operand from
memory to register B
0006 SUB B 90 Subtract B from A
0007 MOV M,A 77 Move result from register A
to memory
0008 HLT 76 Halt
Explanation:
1. This program subtracts two operands stored in memory
location 4500H without considering the borrow.
2. Let us assume that the operand stored at memory location
is 4500H, operand 1 is 08H and operand 2 is 01H.
3. Initially HL pair is loaded with address of just memory
location.
4. The first operand is moved to accumulator from memory
location 4500H and HL pair is incremented to point to
next memory location.
5. The second operand is moved to register B from memory
location 4500H.
6. The two operands are subtracted and stored in accumulator
7. HL pair is again incremented and the result is moved to
accumulator to memory location 4502H.
Output:
- Before execution
4500H: 08H
4501H: 01H
- After execution
4502H: 07H