diff options
author | Rangi <35663410+Rangi42@users.noreply.github.com> | 2020-07-07 19:48:22 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-07 19:48:22 -0400 |
commit | 9571c550b6a0dcb3a4f54513c881661a87271024 (patch) | |
tree | d73507228a57e4f3cece2fb93fe7df3a9439553f /home/math.asm | |
parent | c480632d5494d04f7f5f0298a31877a2293b564e (diff) | |
parent | bbf2f51a02b2544f1bef32a5868503b474ae2fef (diff) |
Merge pull request #263 from Rangi42/master
Syncing style with pokecrystal
Diffstat (limited to 'home/math.asm')
-rw-r--r-- | home/math.asm | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/home/math.asm b/home/math.asm new file mode 100644 index 00000000..b081b540 --- /dev/null +++ b/home/math.asm @@ -0,0 +1,41 @@ +; function to do multiplication +; all values are big endian +; INPUT +; FF96-FF98 = multiplicand +; FF99 = multiplier +; OUTPUT +; FF95-FF98 = product +Multiply:: + push hl + push bc + callfar _Multiply + pop bc + pop hl + ret + +; function to do division +; all values are big endian +; INPUT +; FF95-FF98 = dividend +; FF99 = divisor +; b = number of bytes in the dividend (starting from FF95) +; OUTPUT +; FF95-FF98 = quotient +; FF99 = remainder +Divide:: + push hl + push de + push bc + ldh a, [hLoadedROMBank] + push af + ld a, BANK(_Divide) + ldh [hLoadedROMBank], a + ld [MBC1RomBank], a + call _Divide + pop af + ldh [hLoadedROMBank], a + ld [MBC1RomBank], a + pop bc + pop de + pop hl + ret |