LARGEST ELEMENT IN AN ARRAY
ADDRE
SS
|
OPCO
DE
|
LABEL
|
MNEM
ONICS
|
OPER
AND
|
COMMENTS
|
8001
|
|
|
LXI
|
H,8100
|
Initialize HL reg. to
8100H
|
8002
|
|
|
|
|
|
8003
|
|
|
|
|
|
8004
|
|
|
MVI
|
B,04
|
Initialize B reg with no. of
comparisons(n-1)
|
8005
|
|
|
|
|
|
8006
|
|
|
MOV
|
A,M
|
Transfer
first data to acc.
|
8007
|
|
LOOP1
|
INX
|
H
|
Increment
HL reg. to point next memory location
|
8008
|
|
|
CMP
|
M
|
Compare M & A
|
8009
|
|
|
JNC
|
|
If A is greater than M then go to loop
|
800A
|
|
|
|
|
|
800B
|
|
|
|
|
|
800C
|
|
|
MOV
|
A,M
|
Transfer data from M to A reg
|
800D
|
|
|
DCR
|
B
|
Decrement B reg
|
800E
|
|
|
JNZ
|
LOOP1
|
If B is not Zero go to loop1
|
800F
|
|
|
|
|
|
8010
|
|
|
|
|
|
8011
|
|
|
STA
|
8105
|
Store the result in a memory location.
|
8012
|
|
|
|
|
|
8013
|
|
|
|
|
|
8014
|
|
|
HLT
|
|
Stop the program
|
Comments
Post a Comment