pokegold-spaceworld/engine/bcd.asm
luckytyphlosion e1659ecd41 Introduce linkerscript.
Addresses of sections will now be added to the linkerscript via `org`, and the section name will be the path/to/file. If there is more than one section in the file, then add a @SectionName after the path/to/file to describe the section.
2018-07-03 17:07:05 -04:00

55 lines
479 B
NASM
Executable File

INCLUDE "constants.asm"
SECTION "engine/bcd.asm", ROMX
AddBCD: ; 03:4de3
and a
ld b, c
.add
ld a, [de]
adc [hl]
daa
ld [de], a
dec de
dec hl
dec c
jr nz, .add
jr nc, .done
ld a, $99
inc de
.fill
ld [de], a
inc de
dec b
jr nz, .fill
.done
ret
SubBCD: ; 03:4df9
and a
ld b, c
.sub
ld a, [de]
sbc [hl]
daa
ld [de], a
dec de
dec hl
dec c
jr nz, .sub
jr nc, .done
ld a, 0
inc de
.fill
ld [de], a
inc de
dec b
jr nz, .fill
scf
.done
ret