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
|
8000
|
|
START
|
LHLD
|
8050H
|
Load the augend in HL pair
|
8001
|
|
|
|
|
|
8002
|
|
|
|
|
|
8003
|
|
|
XCHG
|
|
Load augend in DE pair through HL pair.
|
8004
|
|
|
LHLD
|
8052H
|
Load the addend in HL pair
|
8005
|
|
|
|
|
|
8006
|
|
|
|
|
|
8007
|
|
|
MVI
|
A, 00H
|
Initialize reg. A for carry
|
8008
|
|
|
|
|
|
8009
|
|
|
DAD
|
D
|
Add the contents of HL
Pair
with that of DE pair.
|
800A
|
|
|
JNC
|
LOOP
|
If there is no carry, go to the instruction labeled
LOOP.
|
800B
|
|
|
|
|
|
800C
|
|
|
|
|
|
800D
|
|
|
INR
|
A
|
Otherwise increment
register A
|
800E
|
|
LOOP
|
SHLD
|
8054H
|
Store the content of HL Pair in 8054H
(LSB
of sum)
|
800F
|
|
|
|
|
|
8010
|
|
|
|
|
|
8011
|
|
|
STA
|
8056H
|
Store the carry in 8056H through Acc.
(MSB
of sum).
|
8012
|
|
|
|
|
|
8013
|
|
|
|
|
|
8014
|
|
|
RST 5
|
|
Stop the program.
|
OBSERVATION:
INPUT
|
OUTPUT
|
|||||
ADDRESS
|
DATA
|
ADDRESS
|
DATA
|
|||
8050H
|
|
8054H
|
|
|||
8051H
|
|
8055H
|
|
|||
8052H
|
|
8056H
|
|
|||
8053H
|
|
|
|
|||
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
|
8000
|
|
START
|
MVI
|
C, 00
|
Initialize C reg.
|
8001
|
|
|
|
|
|
8002
|
|
|
LHLD
|
8050H
|
Load the subtrahend in DE reg. Pair through HL reg.
pair.
|
8003
|
|
|
|
|
|
8004
|
|
|
|
|
|
8005
|
|
|
XCHG
|
|
|
8006
|
|
|
LHLD
|
8052H
|
Load the minuend in HL reg. Pair.
|
8007
|
|
|
|
|
|
8008
|
|
|
|
|
|
8009
|
|
|
MOV
|
A, L
|
Move content of reg. L to Acc.
|
800A
|
|
|
SUB
|
E
|
Subtract the content of reg. E from that of acc.
|
800B
|
|
|
MOV
|
L, A
|
Move content of Acc. to reg. L
|
800C
|
|
|
MOV
|
A, H
|
Move content of reg. H to Acc.
|
800D
|
|
|
SBB
|
D
|
Subtract content of reg. D with that of Acc.
|
800E
|
|
|
MOV
|
H, A
|
Transfer content of acc. to reg. H
|
800F
|
|
|
SHLD
|
8054H
|
Store the content of HL pair in memory location 8054H.
|
8010
|
|
|
|
|
|
8011
|
|
|
|
|
|
8012
|
|
|
JNC
|
NEXT
|
If there is borrow, go to the instruction labeled
NEXT.
|
8013
|
|
|
|
|
|
8014
|
|
|
|
|
|
8015
|
|
|
INR
|
C
|
Increment reg. C
|
8016
|
|
NEXT
|
MOV
|
A, C
|
Transfer the content of reg. C to Acc.
|
8017
|
|
|
STA
|
8056H
|
Store the content of acc. to the memory location 8056H
|
8018
|
|
|
|
|
|
8019
|
|
|
|
|
|
801A
|
|
|
RST 5
|
|
Stop the program execution.
|
OBSERVATION:
INPUT
|
OUTPUT
|
|||||
ADDRESS
|
DATA
|
ADDRESS
|
DATA
|
|||
8050H
|
|
8054H
|
|
|||
8051H
|
|
8055H
|
|
|||
8052H
|
|
8056H
|
|
|||
8053H
|
|
|
|
|||
16 BIT MULTIPLICATION
AIM:
To multiply two 16 bit numbers and store the result
in memory.
ALGORITHM:
- Get the multiplier and multiplicand.
- Initialize a register to store partial
product.
- Add multiplicand, multiplier times.
- 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
|
8000
|
|
START
|
LHLD
|
8050
|
Load the first No. in stack pointer through HL reg. pair
|
8001
|
|
|
|
|
|
8002
|
|
|
|
|
|
8003
|
|
|
SPHL
|
|
|
8004
|
|
|
LHLD
|
8052
|
Load the second No. in HL reg. pair & Exchange with DE reg. pair.
|
8005
|
|
|
|
|
|
8006
|
|
|
|
|
|
8007
|
|
|
XCHG
|
|
|
8008
|
|
|
LXI
|
H, 0000H
|
Clear HL & DE reg. pairs.
|
8009
|
|
|
|
|
|
800A
|
|
|
|
|
|
800B
|
|
|
LXI
|
B, 0000H
|
|
800C
|
|
|
|
|
|
800D
|
|
|
|
|
|
800E
|
|
LOOP
|
DAD
|
SP
|
Add SP with HL pair.
|
800F
|
|
|
JNC
|
NEXT
|
If there is no carry, go to the instruction labeled NEXT
|
8010
|
|
|
|
|
|
8011
|
|
|
|
|
|
8012
|
|
|
INX
|
B
|
Increment BC reg. pair
|
8013
|
|
NEXT
|
DCX
|
D
|
Decrement DE reg. pair.
|
8014
|
|
|
MOV
|
A,E
|
Move the content of reg. E to Acc.
|
8015
|
|
|
ORA
|
D
|
OR Acc. with D reg.
|
8016
|
|
|
JNZ
|
LOOP
|
If there is no zero, go to instruction labeled LOOP
|
8017
|
|
|
|
|
|
8018
|
|
|
|
|
|
8019
|
|
|
SHLD
|
8054
|
Store the content of HL pair inmemory locations 8054 & 4055.
|
801A
|
|
|
|
|
|
801B
|
|
|
|
|
|
801C
|
|
|
MOV
|
A, C
|
Move the content of reg. C to Acc.
|
801D
|
|
|
STA
|
8056
|
Store the content of Acc. in memory location 8056.
|
801E
|
|
|
|
|
|
801F
|
|
|
|
|
|
8020
|
|
|
MOV
|
A, B
|
Move the content of reg. B to Acc.
|
8021
|
|
|
STA
|
8057
|
Store the content of Acc. in memory location 8057.
|
8022
|
|
|
|
|
|
8023
|
|
|
|
|
|
8024
|
|
|
RST 5
|
|
Stop program execution
|
OBSERVATION:
INPUT
|
OUTPUT
|
||
ADDRESS
|
DATA
|
ADDRESS
|
DATA
|
8050
|
|
8054
|
|
8051
|
|
8055
|
|
8052
|
|
8056
|
|
8053
|
|
8057
|
|
16- BIT DIVISION
AIM:
To
divide two 16-bit numbers and store the result in memory using 8085 mnemonics.
ALGORITHM:
- Get the dividend and divisor.
- Initialize the register for quotient.
- Repeatedly subtract divisor from dividend
till dividend becomes less than divisor.
- Count the number of subtraction which equals
the quotient.
- 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
|
8000
|
|
START
|
LHLD
|
8050
|
Load the first No. in stack pointer through HL reg. pair
|
8001
|
|
|
|
|
|
8002
|
|
|
|
|
|
8003
|
|
|
XCHG
|
|
|
8004
|
|
|
LHLD
|
8052
|
Load the second No. in HL reg. pair & Exchange with DE reg. pair.
|
8005
|
|
|
|
|
|
8006
|
|
|
|
|
|
8007
|
|
|
LXI
|
B, 0000H
|
Clear BC reg. pair.
|
8008
|
|
|
|
|
|
8009
|
|
|
|
|
|
800A
|
|
LOOP
|
MOV
|
A, L
|
Move the content of reg. L to Acc.
|
800B
|
|
|
SUB
|
E
|
Subtract reg. E from that of Acc.
|
800C
|
|
|
MOV
|
L, A
|
Move the content of Acc to L.
|
800D
|
|
|
MOV
|
A, H
|
Move the content of reg. H Acc.
|
800E
|
|
|
SBB
|
D
|
Subtract reg. D from that of
Acc.
|
800F
|
|
|
MOV
|
H, A
|
Move the content of Acc to H.
|
8010
|
|
|
INX
|
B
|
Increment reg. Pair BC
|
8011
|
|
|
JNC
|
LOOP
|
If there is no carry, go to the location labeled LOOP.
|
8012
|
|
|
|
|
|
8013
|
|
|
|
|
|
8014
|
|
|
DCX
|
B
|
Decrement BC reg. pair.
|
8015
|
|
|
DAD
|
D
|
Add content of HL and DE reg. pairs.
|
8016
|
|
|
SHLD
|
8054
|
Store the content of HL pair in 8054 & 8055.
|
8017
|
|
|
|
|
|
8018
|
|
|
|
|
|
8019
|
|
|
MOV
|
A, C
|
Move the content of reg. C to Acc.
|
801A
|
|
|
STA
|
8056
|
Store the content of Acc. in memory 8056
|
801B
|
|
|
|
|
|
801C
|
|
|
|
|
|
801D
|
|
|
MOV
|
A, B
|
Move the content of reg. B to Acc.
|
801E
|
|
|
STA
|
8057
|
Store the content of Acc. in memory 8057.
|
801F
|
|
|
|
|
|
8020
|
|
|
|
|
|
8021
|
|
|
RST 5
|
|
Stop the program execution.
|
OBSERVATION:
INPUT
|
OUTPUT
|
||
ADDRESS
|
DATA
|
ADDRESS
|
DATA
|
8050
|
|
8054
|
|
8051
|
|
8055
|
|
8052
|
|
8056
|
|
8053
|
|
8057
|
|
No comments:
Post a Comment