Cycle:1
Data Transfer and Arithmetic Operations Using 8085
1. The 8085 programming model
2. 8 bit data addition
3. 8 bit data subtraction
4. 8 bit data multiplication
5. 8 bit division
6. 16 bit data addition
7. 16 bit data subtraction
8. 16 bit multiplication
9. 16- bit division
Data Transfer and Arithmetic Operations Using 8085
1. The 8085 programming model
2. 8 bit data addition
3. 8 bit data subtraction
4. 8 bit data multiplication
5. 8 bit division
6. 16 bit data addition
7. 16 bit data subtraction
8. 16 bit multiplication
9. 16- bit division
2. 8 BIT DATA ADDITION
AIM:
To add two 8 bit numbers stored at consecutive
memory locations.
ALGORITHM:
1. Initialize
memory pointer to data location.
2. Get the first
number from memory in accumulator.
3. Get the
second number and add it to the accumulator.
4. Store the
answer at another memory location.
RESULT:
8
bit numbers stored at 4500 &4501 are added and the result stored at 4502
& 4503.
PROGRAM:
ADDRESS
|
OPCODE
|
LABEL
|
MNEMONICS
|
OPERAND
|
COMMENT
|
4100
|
|
START
|
MVI
|
C, 00
|
Clear C reg.
|
4101
|
|
|
|
|
|
4102
|
|
|
LXI
|
H, 4500
|
Initialize HL reg. to 4500
|
4103
|
|
|
|
|
|
4104
|
|
|
|
|
|
4105
|
|
|
MOV
|
A, M
|
Transfer first data to accumulator
|
4106
|
|
|
INX
|
H
|
Increment HL reg. to point next
memory location.
|
4107
|
|
|
ADD
|
M
|
Add first number to acc. Content.
|
4108
|
|
|
JNC
|
L1
|
Jump to location if result does
not yield carry.
|
4109
|
|
|
|
|
|
410A
|
|
|
|
|
|
410B
|
|
|
INR
|
C
|
Increment C reg.
|
410C
|
|
L1
|
INX
|
H
|
Increment HL reg. to point next
memory location.
|
410D
|
|
|
MOV
|
M, A
|
Transfer the result from acc. to
memory.
|
410E
|
|
|
INX
|
H
|
Increment HL reg. to point next
memory location.
|
410F
|
|
|
MOV
|
M, C
|
Move carry to memory
|
4110
|
|
|
RST 1
|
|
Stop the program
|
OBSERVATION:
INPUT
|
OUTPUT
|
||
ADDRESS
|
DATA
|
ADDRESS
|
DATA
|
4500
|
|
4502
|
|
4501
|
|
4503
|
|
3)
8 BIT DATA SUBTRACTION
AIM:
To subtract two 8 bit numbers stored at
consecutive memory locations.
ALGORITHM:
1. Initialize
memory pointer to data location.
2. Get the
first number from memory in accumulator.
3. Get the
second number and subtract from the accumulator.
4. If the
result yields a borrow,
a.
The
content of the acc. is complemented and 01H is added to it (2’s complement).
b. A register
is cleared and the content of that reg. is incremented to store borrow.
5. If there
is no borrow the content of the acc. is directly taken as the result.
6. Store the
answer (in the accumulator and register) at next memory location.
RESULT:
Thus
the 8 bit numbers stored at 4500 &4501 are subtracted and the result stored
at 4502 & 4503.
PROGRAM:
ADDRESS
|
OPCODE
|
LABEL
|
MNEMONICS
|
OPERAND
|
COMMENT
|
4100
|
|
START
|
MVI
|
C, 00
|
Clear C reg.
|
4101
|
|
|
|
|
|
4102
|
|
|
LXI
|
H, 4500
|
Initialize HL reg. to
4500
|
4103
|
|
|
|
|
|
4104
|
|
|
|
|
|
4105
|
|
|
MOV
|
A, M
|
Transfer first data to accumulator
|
4106
|
|
|
INX
|
H
|
Increment HL reg. to point next
mem. Location.
|
4107
|
|
|
SUB
|
M
|
Subtract first number from acc.
Content.
|
4108
|
|
|
JNC
|
L1
|
Jump to location if result does not
yield borrow.
|
4109
|
|
|
|
|
|
410A
|
|
|
|
|
|
410B
|
|
|
INR
|
C
|
Increment C reg.
|
410C
|
|
|
CMA
|
|
Complement the Acc. content
|
410D
|
|
|
ADI
|
01H
|
Add 01H to content of acc.
|
410E
|
|
|
|
|
|
410F
|
|
L1
|
INX
|
H
|
Increment HL reg. to point next
mem. Location.
|
4110
|
|
|
MOV
|
M, A
|
Transfer the result from acc. to
memory.
|
4111
|
|
|
INX
|
H
|
Increment HL reg. to point next
mem. Location.
|
4112
|
|
|
MOV
|
M, C
|
Move carry to mem.
|
4113
|
|
|
RST 1
|
|
Stop the program
|
OBSERVATION:
INPUT
|
OUTPUT
|
||
ADDRESS
|
DATA
|
ADDRESS
|
DATA
|
4500
|
|
4502
|
|
4501
|
|
4503
|
|
4.
8 BIT DATA MULTIPLICATION
AIM:
To multiply two 8 bit numbers stored at
consecutive memory locations and store the result in memory.
ALGORITHM:
LOGIC: Multiplication can be done by
repeated addition.
1. Initialize
memory pointer to data location.
2. Move multiplicand
to a register.
3. Move the
multiplier to another register.
4. Clear the
accumulator.
5. Add
multiplicand to accumulator
6. Decrement
multiplier
7. Repeat
step 5 till multiplier comes to zero.
8. The result,
which is in the accumulator, is stored in a memory location.
RESULT:
Thus
the 8-bit multiplication was done in 8085mp using repeated addition method.
PROGRAM:
ADDRESS
|
OPCODE
|
LABEL
|
MNEMONICS
|
OPERAND
|
COMMENT
|
4100
|
|
START
|
LXI
|
H, 4500
|
Initialize HL reg. to 4500
|
4101
|
|
|
|
|
|
4102
|
|
|
|
|
Transfer first data to reg. B
|
4103
|
|
|
MOV
|
B, M
|
|
4104
|
|
|
INX
|
H
|
Increment HL reg. to point next memory location.
|
4105
|
|
|
MVI
|
A, 00H
|
Clear the acc.
|
4106
|
|
|
|
|
|
4107
|
|
|
MVI
|
C, 00H
|
Clear C register for carry
|
4108
|
|
|
|
|
|
4109
|
|
L1
|
ADD
|
M
|
Add multiplicand, multiplier
times.
|
410A
|
|
|
JNC
|
NEXT
|
Jump to NEXT if there is no carry
|
410B
|
|
|
|
|
|
410C
|
|
|
|
|
|
410D
|
|
|
INR
|
C
|
Increment C register
|
410E
|
|
NEXT
|
DCR
|
B
|
Decrement B register
|
410F
|
|
|
JNZ
|
L1
|
Jump to L1 if B is not zero.
|
4110
|
|
|
|
|
|
4111
|
|
|
|
|
|
4112
|
|
|
INX
|
H
|
Increment HL reg. to point next
memory location.
|
4113
|
|
|
MOV
|
M, A
|
Transfer the result from acc. to
memory.
|
4114
|
|
|
INX
|
H
|
Increment HL reg. to point next memory
location.
|
4115
|
|
|
MOV
|
M, C
|
Transfer the result from C reg.
to memory.
|
4116
|
|
|
RST 1
|
|
Stop the program
|
OBSERVATION:
INPUT
|
OUTPUT
|
||
ADDRESS
|
DATA
|
ADDRESS
|
DATA
|
4500
|
|
4502
|
|
4501
|
|
4503
|
|
5. 8 BIT DIVISION
AIM:
To divide two 8-bit numbers and
store the result in memory.
ALGORITHM:
LOGIC:
Division is done using the method repeated subtraction.
1.
Load
Divisor and Dividend
2.
Subtract
divisor from dividend
3.
Count
the number of times of subtraction which equals the quotient
4.
Stop
subtraction when the dividend is less than the divisor .The dividend now
becomes the remainder. Otherwise go to step 2.
5.
Stop
the program execution.
RESULT:
An ALP was written for 8-bit
division using repeated subtraction method and executed using 8085m p kits
PROGRAM:
ADDRESS
|
OPCODE
|
LABEL
|
MNEMONICS
|
OPERAND
|
COMMENTS
|
4100
|
|
|
MVI
|
B,00
|
Clear B register for quotient
|
4101
|
|
|
|
|
|
4102
|
|
|
LXI
|
H,4500
|
Initialize HL reg. to 4500H
|
4103
|
|
|
|
|
|
4104
|
|
|
|
|
|
4105
|
|
|
MOV
|
A,M
|
Transfer dividend to acc.
|
4106
|
|
|
INX
|
H
|
Increment HL reg. to point next memory location.
|
4107
|
|
LOOP
|
SUB
|
M
|
Subtract divisor from dividend
|
4108
|
|
|
INR
|
B
|
Increment B register
|
4109
|
|
|
JNC
|
LOOP
|
Jump to LOOP if
result does not yield borrow
|
410A
|
|
|
|
|
|
410B
|
|
|
|
|
|
410C
|
|
|
ADD
|
M
|
Add divisor to acc.
|
410D
|
|
|
DCR
|
B
|
Decrement B register
|
410E
|
|
|
INX
|
H
|
Increment HL reg. to point next
memory location.
|
410F
|
|
|
MOV
|
M,A
|
Transfer the remainder from acc.
to memory.
|
4110
|
|
|
INX
|
H
|
Increment HL reg. to point next
memory location.
|
4111
|
|
|
MOV
|
M,B
|
Transfer the quotient from B reg.
to memory.
|
4112
|
|
|
RST 1
|
|
Stop the program
|
OBSERVATION:
INPUT
|
OUTPUT
|
||
ADDRESS
|
DATA
|
ADDRESS
|
DATA
|
4500
|
|
4502
|
|
4501
|
|
4503
|
|
|
|
|
|
6.
16 BIT DATA ADDITION
AIM:
To add two 16-bit numbers stored at
consecutive memory locations.
ALGORITHM:
1. Initialize
memory pointer to data location.
2. Get the
first number from memory and store in Register pair.
3. Get the
second number in memory and add it to the Register pair.
4. Store the
sum & carry in separate memory locations.
RESULT:
An
ALP program for 16-bit addition was written and executed in 8085mp using special instructions.
PROGRAM:
ADDRESS
|
OPCODE
|
LABEL
|
MNEMONICS
|
OPERAND
|
COMMENT
|
4000
|
|
START
|
LHLD
|
4050H
|
Load the augend in HL pair
|
4001
|
|
|
|
|
|
4002
|
|
|
|
|
|
4003
|
|
|
XCHG
|
|
Load augend in DE pair through HL
pair.
|
4004
|
|
|
LHLD
|
4052H
|
Load the addend in HL pair
|
4005
|
|
|
|
|
|
4006
|
|
|
|
|
|
4007
|
|
|
MVI
|
A, 00H
|
Initialize reg. A for carry
|
4008
|
|
|
|
|
|
4009
|
|
|
DAD
|
D
|
Add the contents of HL
Pair with that of DE pair.
|
400A
|
|
|
JNC
|
LOOP
|
If there is no carry, go to the
instruction labeled LOOP.
|
400B
|
|
|
|
|
|
400C
|
|
|
|
|
|
400D
|
|
|
INR
|
A
|
Otherwise increment register A
|
400E
|
|
LOOP
|
SHLD
|
4054H
|
Store the content of HL Pair in
4054H
(LSB of sum)
|
400F
|
|
|
|
|
|
4010
|
|
|
|
|
|
4011
|
|
|
STA
|
4056H
|
Store the carry in 4056H through
Acc.
(MSB of sum).
|
4012
|
|
|
|
|
|
4013
|
|
|
|
|
|
4014
|
|
|
RST 1
|
|
Stop the program.
|
OBSERVATION:
INPUT
|
OUTPUT
|
||||
ADDRESS
|
DATA
|
ADDRESS
|
DATA
|
||
4050H
|
|
4054H
|
|
||
4051H
|
|
4055H
|
|
||
4052H
|
|
4056H
|
|
||
4053H
|
|
|
|||
7. 16 BIT DATA SUBTRACTION
AIM:
To subtract two 16-bit numbers stored at consecutive
memory locations.
ALGORITHM:
1.
Initialize
memory pointer to data location.
2.
Get
the subtrahend from memory and transfer it to register pair.
3.
Get
the minuend from memory and store it in another register pair.
4.
Subtract
subtrahend from minuend.
5.
Store
the difference and borrow in different memory locations.
RESULT:
An
ALP program for subtracting two 16-bit numbers was written and executed.
PROGRAM:
ADDRESS
|
OPCODE
|
LABEL
|
MNEMONICS
|
OPER
AND
|
COMMENTS
|
4000
|
|
START
|
MVI
|
C, 00
|
Initialize C reg.
|
4001
|
|
|
|
|
|
4002
|
|
|
LHLD
|
4050H
|
Load the subtrahend in DE reg.
Pair through HL reg. pair.
|
4003
|
|
|
|
|
|
4004
|
|
|
|
|
|
4005
|
|
|
XCHG
|
|
|
4006
|
|
|
LHLD
|
4052H
|
Load the minuend in HL reg. Pair.
|
4007
|
|
|
|
|
|
4008
|
|
|
|
|
|
4009
|
|
|
MOV
|
A, L
|
Move content of reg. L to Acc.
|
400A
|
|
|
SUB
|
E
|
Subtract the content of reg. E from that of acc.
|
400B
|
|
|
MOV
|
L, A
|
Move content of Acc. to reg. L
|
400C
|
|
|
MOV
|
A, H
|
Move content of reg. H to Acc.
|
400D
|
|
|
SBB
|
D
|
Subtract content of reg. D with
that of Acc.
|
400E
|
|
|
MOV
|
H, A
|
Transfer content of acc. to reg. H
|
400F
|
|
|
SHLD
|
4054H
|
Store the content of HL pair in
memory location 4054H.
|
4010
|
|
|
|
|
|
4011
|
|
|
|
|
|
4012
|
|
|
JNC
|
NEXT
|
If there is borrow, go to the instruction
labeled NEXT.
|
4013
|
|
|
|
|
|
4014
|
|
|
|
|
|
4015
|
|
|
INR
|
C
|
Increment reg. C
|
4016
|
|
NEXT
|
MOV
|
A, C
|
Transfer the content of reg. C to
Acc.
|
4017
|
|
|
STA
|
4056H
|
Store the content of acc. to the
memory location 4056H
|
4018
|
|
|
|
|
|
4019
|
|
|
|
|
|
401A
|
|
|
RST 1
|
|
Stop the program execution.
|
OBSERVATION:
INPUT
|
OUTPUT
|
||||
ADDRESS
|
DATA
|
ADDRESS
|
DATA
|
||
4050H
|
|
4054H
|
|
||
4051H
|
|
4055H
|
|
||
4052H
|
|
4056H
|
|
||
4053H
|
|
|
|||
8. 16 BIT MULTIPLICATION
AIM:
To
multiply two 16 bit numbers and store the result in memory.
ALGORITHM:
1.
Get the
multiplier and multiplicand.
2.
Initialize
a register to store partial product.
3.
Add
multiplicand, multiplier times.
4.
Store
the result in consecutive memory locations.
RESULT:
16-bit
multiplication was done in 8085mp
using repeated addition method.
PROGRAM:
ADDRESS
|
OPCODE
|
LABEL
|
MNEMONICS
|
OPERAND
|
COMMENTS
|
4000
|
|
START
|
LHLD
|
4050
|
Load the first No. in stack pointer through HL reg. pair
|
4001
|
|
|
|
|
|
4002
|
|
|
|
|
|
4003
|
|
|
SPHL
|
|
|
4004
|
|
|
LHLD
|
4052
|
Load the second No. in HL reg. pair & Exchange with DE
reg. pair.
|
4005
|
|
|
|
|
|
4006
|
|
|
|
|
|
4007
|
|
|
XCHG
|
|
|
4008
|
|
|
LXI
|
H, 0000H
|
Clear HL & DE reg. pairs.
|
4009
|
|
|
|
|
|
400A
|
|
|
|
|
|
400B
|
|
|
LXI
|
B, 0000H
|
|
400C
|
|
|
|
|
|
400D
|
|
|
|
|
|
400E
|
|
LOOP
|
DAD
|
SP
|
Add SP with HL pair.
|
400F
|
|
|
JNC
|
NEXT
|
If there is no carry, go to the instruction labeled NEXT
|
4010
|
|
|
|
|
|
4011
|
|
|
|
|
|
4012
|
|
|
INX
|
B
|
Increment BC reg. pair
|
4013
|
|
NEXT
|
DCX
|
D
|
Decrement DE reg. pair.
|
4014
|
|
|
MOV
|
A,E
|
Move the content of reg. E to Acc.
|
4015
|
|
|
ORA
|
D
|
OR Acc. with D reg.
|
4016
|
|
|
JNZ
|
LOOP
|
If there is no zero, go to instruction labeled LOOP
|
4017
|
|
|
|
|
|
4018
|
|
|
|
|
|
4019
|
|
|
SHLD
|
4054
|
Store the content of HL pair in memory locations 4054
& 4055.
|
401A
|
|
|
|
|
|
401B
|
|
|
|
|
|
401C
|
|
|
MOV
|
A, C
|
Move the content of reg. C to Acc.
|
401D
|
|
|
STA
|
4056
|
Store the content of Acc. in memory location 4056.
|
401E
|
|
|
|
|
|
401F
|
|
|
|
|
|
4020
|
|
|
MOV
|
A, B
|
Move the content of reg. B to Acc.
|
4021
|
|
|
STA
|
4057
|
Store the content of Acc. in memory location 4057.
|
4022
|
|
|
|
|
|
4023
|
|
|
|
|
|
4024
|
|
|
RST 1
|
|
Stop program execution
|
OBSERVATION:
INPUT
|
OUTPUT
|
||
ADDRESS
|
DATA
|
ADDRESS
|
DATA
|
4050
|
|
4054
|
|
4051
|
|
4055
|
|
4052
|
|
4056
|
|
4053
|
|
4057
|
|
9. 16- BIT DIVISION
AIM:
To divide two 16-bit numbers and store the result
in memory using 8085 mnemonics.
ALGORITHM:
1. Get the
dividend and divisor.
2. Initialize
the register for quotient.
3. Repeatedly
subtract divisor from dividend till dividend becomes less than divisor.
4. Count
the number of subtraction which equals the quotient.
5. Store
the result in memory.
RESULT:
The
16-bit Division was done in 8085mp using repeated subtraction method.
PROGRAM:
ADDRESS
|
OPCODE
|
LABEL
|
MNEMONICS
|
OPERAND
|
COMMENTS
|
4000
|
|
START
|
LHLD
|
4052
|
Load the first No. in stack pointer through HL reg. pair
|
4001
|
|
|
|
|
|
4002
|
|
|
|
|
|
4003
|
|
|
XCHG
|
|
|
4004
|
|
|
LHLD
|
4050
|
Load the second No. in HL reg. pair & Exchange with DE
reg. pair.
|
4005
|
|
|
|
|
|
4006
|
|
|
|
|
|
4007
|
|
|
LXI
|
B, 0000H
|
Clear BC reg. pair.
|
4008
|
|
|
|
|
|
4009
|
|
|
|
|
|
400A
|
|
LOOP
|
MOV
|
A, L
|
Move the content of reg. L to Acc.
|
400B
|
|
|
SUB
|
E
|
Subtract reg. E from that of Acc.
|
400C
|
|
|
MOV
|
L, A
|
Move the content of Acc to L.
|
400D
|
|
|
MOV
|
A, H
|
Move the content of reg. H Acc.
|
400E
|
|
|
SBB
|
D
|
Subtract reg. D from that of Acc.
|
400F
|
|
|
MOV
|
H, A
|
Move the content of Acc to H.
|
4010
|
|
|
INX
|
B
|
Increment reg. Pair BC
|
4011
|
|
|
JNC
|
LOOP
|
If there is no carry, go to the location labeled LOOP.
|
4012
|
|
|
|
|
|
4013
|
|
|
|
|
|
4014
|
|
|
DCX
|
B
|
Decrement BC reg. pair.
|
4015
|
|
|
DAD
|
D
|
Add content of HL and DE reg.
pairs.
|
4016
|
|
|
SHLD
|
4054
|
Store the content of HL pair in 4054 & 4055.
|
4017
|
|
|
|
|
|
4018
|
|
|
|
|
|
4019
|
|
|
MOV
|
A, C
|
Move the content of reg. C to Acc.
|
401A
|
|
|
STA
|
4056
|
Store the content of Acc. in memory 4056
|
401B
|
|
|
|
|
|
401C
|
|
|
|
|
|
401D
|
|
|
MOV
|
A, B
|
Move the content of reg. B to Acc.
|
401E
|
|
|
STA
|
4057
|
Store the content of Acc. in memory 4057.
|
401F
|
|
|
|
|
|
4020
|
|
|
|
|
|
4021
|
|
|
RST 1
|
|
Stop the program execution.
|
OBSERVATION:
INPUT
|
OUTPUT
|
||
ADDRESS
|
DATA
|
ADDRESS
|
DATA
|
4050
|
|
4054
|
|
4051
|
|
4055
|
|
4052
|
|
4056
|
|
4053
|
|
4057
|
|
No comments:
Post a Comment