Addition of two 8-bit numbers using 8085
Ø An
Assembly Language Program to perform addition of two 8-bit numbers using 8085?
Algorithm
1) Start
the program by loading the first data into Accumulator.
2) Copy
the data to a register.
3) Get
the second data and load into Accumulator.
4) Add
the two register contents.
5) Check
for carry.
6) Store
the value of sum and carry in memory location.
7) Terminate
the program.
Program
MEMORY
|
LABEL
|
MNEMONIC
|
OPCODE
|
COMMENT
|
4200
|
MVI C,00
|
OE
|
Initialize C
register to 00
|
|
4201
|
00
|
|||
4202
|
LDA 4500
|
3A
|
Load value to
accumulator
|
|
4203
|
00
|
|||
4204
|
45
|
|||
4205
|
MOV B, A
|
47
|
Copy the
content of Accumulator to B register.
|
|
4206
|
LDA 4501
|
3A
|
Load the value
to Accumulator
|
|
4207
|
01
|
|||
4208
|
45
|
|||
4209
|
ADD B
|
80
|
Add the value
of register B to A
|
|
420A
|
JNC LOOP
|
D2
|
Jump on no
carry
|
|
420B
|
0E
|
|||
420C
|
42
|
|||
420D
|
INR C
|
OC
|
Increment
value register C
|
|
420E
|
LOOP
|
STA 4100
|
32
|
Store the
value of Accumulator
|
420F
|
00
|
|||
4210
|
45
|
|||
4211
|
MOV A,C
|
79
|
Copy the
content of register C to Accumulator
|
|
4212
|
STA 4101
|
32
|
Store the
value of Accumulator (CARRY)
|
|
4213
|
01
|
|||
4214
|
41
|
|||
4215
|
HLT
|
76
|
Halt the
program
|
Observation
Input at 4500 : 32H
4501 : FFH
Output at 4100 : 31H
4101 : 01H
--------------------------------------------------------------------------------------------------
Ø An Assembly Language Program to perform subtraction of two 8-bit numbers using 8085?
Algorithm
1) Start
the program by loading the first data into Accumulator.
2) Copy
the data to the accumulator.
3) Get
the second data and load into a register.
4) Subtract
the two register contents.
5) Check
for carry.
6) If
carry is present take 2’s complement of Accumulator.
7) Store
the value of borrow in memory location.
8) Store
the difference value in Accumulator to a memory location.
9) Terminate
the program.
Program
MEMORY
|
LABEL
|
MNEMONIC
|
OPCODE
|
COMMENT
|
4200
|
MVI C,00
|
OE
|
Initialize C
register to 00
|
|
4201
|
00
|
|||
4202
|
LXI H, 4500
|
21
|
Load address
of 1st number to H-L pair
|
|
4203
|
00
|
|||
4204
|
45
|
|||
4205
|
MOV A, M
|
7E
|
Copy 1st
number to Accumulator
|
|
4206
|
INX H
|
23
|
Increment
memory
|
|
4207
|
MOV B,M
|
46
|
Copy 2nd
number to register B
|
|
4208
|
SUB B
|
90
|
Subtract 2nd
number from 1st
|
|
4209
|
JNC GOTO
|
D2
|
Jump on no
carry to label GOTO
|
|
420A
|
OF
|
|||
420B
|
42
|
|||
420C
|
INR C
|
OC
|
Increment C by
1
|
|
420D
|
CMA
|
2F
|
Complement
register A
|
|
420E
|
INR A
|
3C
|
Increment A by
1
|
|
420F
|
GOTO
|
STA 4100
|
32
|
Store
Accumulator content to 4100
|
4210
|
00
|
|||
4211
|
41
|
|||
4212
|
MOV A,C
|
79
|
Copy carry to
the accumulator
|
|
4213
|
STA 4101
|
32
|
Store
accumulator content to 4101
|
|
4214
|
01
|
|||
4215
|
41
|
|||
4216
|
HLT
|
76
|
Halt the
program
|
Observation
Input at 4500 : 06H
4501 : 09H
Output at 4100 : 03H
4101 : 01H
--------------------------------------------------------------------------------------------------
No comments:
Post a Comment