Program to find largest of n numbers
18. Program to find largest of n numbers :
mov r0,#10h ;move immediate data 10h to r0.mov a,@r0 ;move data from internal RAM location to a
mov r2,a ;move data from a to r2
dec r2 ;decrement r2
inc r0 ;increment r0
mov a,@r0 ;move data from internal RAM location to a
l2:push 0e0h ;save the content of a on stack
inc r0 ;increment r0
subb a,@r0 ;subtract content of internal RAM location from a
jnc down ;if no carry, jump to label down
mov a,@r0 ; move data from internal RAM location to a
sjmp d1 ;jump to location d1
down:pop 0e0h ;pop a from stack
d1:djnz r2,l2 ;decrement r2, if not zero, jump to location l2
inc r0 ;increment r0
mov @r0,a ;move data from a to internal RAM location
here:sjmp here
end