1.Program to add two multibyte numbers.
mov r4,#0h ;move 00 to r4
mov r3,#0h ;move 00 to r3
mov dptr,#9000h ; Load 9000h into dptr register
movx a,@dptr ;move the data from memory location to a register
mov r0,a ;move the data from a to r0
inc dptr ;increment dptr
movx a,@dptr ;move the data from memory location to a
mov r1,a ;move the data from a register to r1
inc dptr ;increment dptr
movx a,@dptr ;move the data from memory to a
mov r2,a ;move the data form a to r2
inc dptr ;increment dptr
movx a,@dptr ; move the data from memory location to a register
clr c ;clear carry bit
add a,r1 ;add a and r1
jnc res ;if no carry, jump to label res
mov r3,a ;move data from a to r3
mov a,r0 ;move data from r0 to a
addc a,r2 ; add with carry and r2
jnc end1 ;if no carry, jump to label end1
inc r4 ;increment r4
ajmp end1 ;jump to label end1
res:mov r3,a ; move data from a to r3
mov a,r0 ; move data from r0 to a
add a,r2 ;add a and r2
jnc end1 ; if no carry, jump to label end1
inc r4 ;increment r4
end1:mov r5,a ;move data from a to r5
mov dptr,#900ah ;load 9000h into dptr register
mov a,r4 ; move data from r4 to a
movx @dptr,a ;move data from a to memory location
mov a,r5 ;move data from r5 to a
inc dptr ;increment dptr
movx @dptr,a ; move data from a to memory location
mov a,r3 ; move data from r3 to a
inc dptr ; increment dptr
movx @dptr,a ; move data from a to memory location
here:sjmp here
end
Input Location:9000h,9001h,9002h,9003h
Output Location:900ah
Input Data: 1111 1111(hex)
Output : 2222h
0 comments:
Post a Comment