Krolyxon
Commit c48ef97

Branches

Tags

Refs →

bench51examplesbcd_add.asm

21 lines · 651 B · x86_64 Assembly

1; Packed BCD addition with DA A: 4-digit 1234 + 5678 = 6912.
2; Watch A, CY and AC in the Registers panel while stepping.
3
4 ORG 0000h
5 MOV R0,#34h ; low byte of first number
6 MOV R1,#12h ; high byte
7 MOV R2,#78h ; low byte of second number
8 MOV R3,#56h ; high byte
9
10 MOV A,R0
11 ADD A,R2 ; 34h + 78h = ACh (binary)
12 DA A ; -> 12h, CY = 1
13 MOV 30h,A
14 MOV A,R1
15 ADDC A,R3 ; 12h + 56h + carry
16 DA A ; -> 69h
17 MOV 31h,A ; result 6912 in 31h:30h
18
19 SJMP $
20
21 END