mov dptr,#9000h ;Load dptr with immediate data 9000h
movx a,@dptr ;move data from external memory location to a
mov r0,a ;move data from a to r0
mov b,r0 ;move data from r0 to b
inc dptr ;increment dptr
movx a,@dptr ; move data from external memory location to a
mov r2,a ;move data from a to r2
l2:push 0e0h ;push a onto the stack
div ab ;divide a by b
mov r1,b ;move data from b to r1
cjne r1,#00,l1 ;compare r1 with 0, if not equal, jump to label l1
pop 0e0h ;pop a from satck
inc dptr ;increment dptr
movx @dptr,a ;move data from a to external memory location
sjmp here
l1:pop 0e0h ;pop a from stack
add a,r2 ;add a and r2
mov b,r0 ;move data from r0 to b
sjmp l2
here:sjmp here
end
Input: 05 02
Output:0ah
0 comments:
Post a Comment