diff options
author | libjet <libj3t@gmail.com> | 2020-02-18 18:34:17 +0000 |
---|---|---|
committer | libjet <libj3t@gmail.com> | 2020-02-18 18:34:17 +0000 |
commit | 6cbd16985aaa5408f855454c55a073d753b38d8c (patch) | |
tree | 6ee722544f89bc12d5b8b6376c4aa6a0f5283327 /home/math.asm | |
parent | 76b10c0a49ee07470a326804588217b1c7b9b59b (diff) |
Update math.asm and add print_text.asm
Diffstat (limited to 'home/math.asm')
-rw-r--r-- | home/math.asm | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/home/math.asm b/home/math.asm index ffa3c282..71de08f9 100644 --- a/home/math.asm +++ b/home/math.asm @@ -1,71 +1,68 @@ -SkipNames:: - ld bc, $b +AddNTimes:: +; Add bc * a to hl. and a ret z -.asm_319e +.loop add hl, bc dec a - jr nz, .asm_319e - ret - -AddNTimes:: ; 31a3 (0:31a3) - and a - ret z -.asm_31a5 - add hl, bc - dec a - jr nz, .asm_31a5 + jr nz, .loop ret SimpleMultiply:: +; Return a * c. and a ret z + push bc ld b, a xor a -.asm_31af +.loop add c dec b - jr nz, .asm_31af + jr nz, .loop pop bc ret - -SimpleDivide:: ; 31b5 (0:31b5) - ld b, $0 -.asm_31b7 + +SimpleDivide:: +; Divide a by c. Return quotient b and remainder a. + ld b, 0 +.loop inc b sub c - jr nc, .asm_31b7 + jr nc, .loop dec b add c ret Multiply:: +; Multiply hMultiplicand (3 bytes) by hMultiplier. Result in hProduct. +; All values are big endian. push hl push bc - callfar Multiply_ ; 1:67bd + callfar _Multiply pop bc pop hl ret Divide:: +; Divide hDividend length b (max 4 bytes) by hDivisor. Result in hQuotient. +; All values are big endian. push hl push de push bc - - homecall Divide_ ; 1:681d - + homecall _Divide pop bc pop de pop hl ret SubtractSigned:: +; Return a - b, sign in carry. sub b ret nc cpl - add $1 + add 1 scf ret |