Some shit software I was messing with on gb
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
514 B

4 years ago
section "home/math.asm", rom0
bits_swap::
ld c, $80
ld b, a
xor a
.loop
rrc b
jr nc, .skip
or c
.skip
rrc c
jr nc, .loop
ret
; TODO: There was a more optimal way to do this with max 16 iterations
array_index::
; hl: array base
; c: entry size
; a: index
and a
ret z
ld b, 0
.loop
add hl, bc
dec a
jr nz, .loop
ret
4 years ago
divide::
; a: value
; c: divisor
; Returns:
; b: result
; a: remainder
4 years ago
ld b, 0
.loop
inc b
sub c
jr nc, .loop
dec b
add c
ret