Transfer a data block using 8085
Ø An
Assembly Language Program to transfer a data block without overlap using 8085?
Algorithm
1) Load
the DE pair with the destination address.
2) Load
the HL pair with the count of elements in the data block.
3) Load
element in the data block.
4) Increment the source address.
5) Copy
the element to the accumulator and then transfer it to the destination address.
6) Increment
destination address.
7) Decrement
the count.
8) If
Count = 0 then go to the next step else go to step 3.
9) Terminate
the program.
Program
MEMORY
|
LABEL
|
MNEMONIC
|
HEX CODE
|
COMMENT
|
4200
|
LXI D,4500
|
11
|
Load
destination address in DE pair
|
|
4201
|
00
|
|||
4202
|
45
|
|||
4203
|
LXI H,4100
|
21
|
Load the count
in HL pair
|
|
4204
|
00
|
|||
4205
|
41
|
|||
4206
|
MOV C,M
|
4E
|
Copy the count
to register C
|
|
4207
|
LOOP
|
INX H
|
23
|
Increment
memory
|
4208
|
MOV A,M
|
7E
|
Copy element
to Accumulator
|
|
4209
|
STAX D
|
12
|
Store the
element to the address in the DE pair
|
|
420A
|
INX D
|
13
|
Increment
destination address
|
|
420B
|
DCR C
|
OD
|
Decrement
count
|
|
420C
|
JNZ LOOP
|
C2
|
Jump on
non-zero to the label LOOP
|
|
420D
|
07
|
|||
420E
|
42
|
|||
420F
|
HLT
|
76
|
Program ends
|
Observation
Input at 4100 : 04H
4101 : 06H
4102 : 07H
4103 : 12H
4104 : 03H
Output at 4500 : 06H
4501 : 07H
4502 : 12H
4503 : 03H
-------------------------------------------------------------------------------------------
Ø An
Assembly Language Program to find the occurrence of an 8-bit number in a given
array of elements using 8085?
Algorithm
1) Load
the HL pair with the address of the element to be found.
2) Copy
the element to accumulator.
3) Load
the count to the C register.
4) Increment
the memory.
5) Compare
accumulator and memory.
6) If
ZF = 0 go to next step else go to step 8.
7) Increment
the occurrence by 1.
8) Decrement
count by 1.
9) If
count = 0 go to next step else go to step 4.
10) Copy
the number of occurrence to accumulator and then to memory.
11) Terminate
the program.
Program
MEMORY
|
LABEL
|
MNEMONIC
|
HEX CODE
|
COMMENT
|
4300
|
MVI B,00
|
06
|
Initialize B
as 0
|
|
4301
|
00
|
|||
4302
|
LXI H,4400
|
21
|
Load HL pair
with the address of the data whose occurrence is to be found
|
|
4303
|
00
|
|||
4304
|
44
|
|||
4305
|
MOV A,M
|
7E
|
Copy the data
to the Accumulator
|
|
4306
|
INX H
|
23
|
Increment
memory
|
|
4307
|
MOV C,M
|
4E
|
Copy the count
to the C register
|
|
4308
|
LOOP
|
INX H
|
23
|
Increment
memory
|
4309
|
CMP M
|
BE
|
Compare memory
and accumulator
|
|
430A
|
JNZ GOTO
|
C2
|
Jump on
non-zero to the label GOTO
|
|
430B
|
0E
|
|||
430C
|
43
|
|||
430D
|
INR B
|
04
|
Increment
occurrence
|
|
430E
|
GOTO
|
DCR C
|
0D
|
Decrement
count
|
430F
|
JNZ LOOP
|
C2
|
Jump on
non-zero to the label LOOP
|
|
4310
|
08
|
|||
4311
|
43
|
|||
4312
|
MOV A,B
|
78
|
Copy the
number of the occurrence to the Accumulator
|
|
4313
|
STA 4415
|
32
|
Store the
accumulator content to 4415
|
|
4314
|
15
|
|||
4315
|
44
|
|||
4316
|
HLT
|
76
|
Program ends
|
Observation
Input at 4400 : 06H ------------ Number
to be checked
4401 : 04H ------------ Count
4402 : 03H
4403 : 06H
4404 : 06H
4405 : 06H
Output at 4415 : 03H ------------ Number
of occurrence
--------------------------------------------------------------------------------------------
No comments:
Post a Comment