mov dptr,#9000h ;Load 9000h into dptr register
movx a,@dptr ;move data from external memory location to a
mov r2,a ;move data from a to r2
clr c ;clear carry bit
subb a,#0ah ;subtract with borrow, 0ah from a
jc over ;if carry, jump to label over
mov a,r2 ;move data from r2 to a
subb a,#064h ;subtract with borrow, 64h from a
jc d1 ; if carry, jump to label d1
mov a,r2 ;move data from r2 to a
mov b,#64h ;move immediate data 64h to b
div ab ;divide a by b
inc dptr ;increment dptr
movx @dptr,a ; move data from external memory location to a
mov a,b ;move data from b to a
mov r3,a ;move data from a to r3
clr c ; clear carry bit
subb a,#0ah ;subtract with borrow, 0ah from a
jc d2 ;if carry, jump to label d2
mov b,#0ah ;Load b with immediate data 0ah
mov a,r3 ;move data from r3 to a
div ab ;divide a by b
inc dptr ;increment dptr
movx @dptr,a ;move data from a to external memory location
mov a,b ;move data from b to a
inc dptr ;increment dptr
movx @dptr,a ;move data from a to external memory location
sjmp end1
d2:mov a,r3 ;move data from r3 to a
inc dptr ;increment dptr
movx @dptr,a ;move data from a to external memory location
sjmp end1
d1:mov a,r2 ;move data from r2 to a
mov b,#0ah ;load b with immediate data 0ah
div ab ;divide a by b
inc dptr ; increment dptr
movx @dptr,a ;move data from a to external memory location
mov a,b ;move data from b to a
inc dptr ;increment dptr
movx @dptr,a ;move data from a to external memory location
sjmp end1
over:mov a,r2 ;move data from r2 to a
inc dptr ;increment dptr
movx @dptr,a ;move data from a to external memory location
here:sjmp here
end1:sjmp end1
end
Input: 0ffh
Output:02 05 05
0 comments:
Post a Comment