ELAN MCU Multi-byte binary addition
Source: Solution Development Department Date: 2020-11-25
Multi-byte binary addition
Add the binary unsigned number in 0X20,0X21 to the binary unsigned number in 0X22,0X23, and put the result in 0X24,0X25,0X26, low ground
Put low byte data in the address.
Main: MOV a, @0x78; assignment
MOV 0x20,a
MOV a,@0xc6
MOV 0x21,a
MOV a,@0x86
MOV 0x22,a
MOV a,@0x9e
MOV 0x23,a
MOV a,@0x0; 0x26 unit is cleared to 0
MOV 0x26,a
MOV a,0x21
add a,0x23
MOV 0x25, a; add the high byte, and send the result 0x25
jbc 0x03,0
inc 0x26; 0x26 plus 1 if there is a carry
MOV a,0x20
add a,0x22
MOV 0x24, a; add the low byte, and send the result 0x24
jbs 0x03,0
jmp self; jump self without carry
inc 0x25; carry 0x25 plus 1
jbc 0x03,0
inc 0x26; Carry 0x26 plus 1
self: jmp self
eop