2018-06-24 07:09:41 -07:00
|
|
|
SimpleMultiply::
|
2013-09-08 22:21:36 -07:00
|
|
|
; Return a * c.
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
push bc
|
|
|
|
ld b, a
|
|
|
|
xor a
|
|
|
|
.loop
|
|
|
|
add c
|
|
|
|
dec b
|
|
|
|
jr nz, .loop
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SimpleDivide::
|
2013-09-08 22:21:36 -07:00
|
|
|
; Divide a by c. Return quotient b and remainder a.
|
|
|
|
ld b, 0
|
|
|
|
.loop
|
|
|
|
inc b
|
|
|
|
sub c
|
|
|
|
jr nc, .loop
|
|
|
|
dec b
|
|
|
|
add c
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Multiply::
|
2013-09-08 22:21:36 -07:00
|
|
|
; Multiply hMultiplicand (3 bytes) by hMultiplier. Result in hProduct.
|
|
|
|
; All values are big endian.
|
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar _Multiply
|
2013-09-08 22:21:36 -07:00
|
|
|
|
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Divide::
|
2013-09-08 22:21:36 -07:00
|
|
|
; Divide hDividend length b (max 4 bytes) by hDivisor. Result in hQuotient.
|
|
|
|
; All values are big endian.
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2016-05-27 07:41:59 -07:00
|
|
|
homecall _Divide
|
2013-09-08 22:21:36 -07:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2020-05-18 08:59:48 -07:00
|
|
|
UnreferencedSubtractAbsolute::
|
|
|
|
; Return |a - b|, sign in carry.
|
2013-09-08 22:21:36 -07:00
|
|
|
sub b
|
|
|
|
ret nc
|
|
|
|
cpl
|
|
|
|
add 1
|
|
|
|
scf
|
|
|
|
ret
|