summaryrefslogtreecommitdiff
path: root/src/home/division.asm
diff options
context:
space:
mode:
authorDaniel Harding <33dannye@gmail.com>2021-09-19 00:21:14 -0500
committerGitHub <noreply@github.com>2021-09-19 00:21:14 -0500
commitdf67aac83b466dadf5f74c881bf84dd9ef19bdfc (patch)
tree47501aced2d256052b8f78bc97328d5af5703add /src/home/division.asm
parente4bce9b7ee5e89f8edfd921de2379f0fa06af206 (diff)
parent8dee6b7a11e85d6d4b9f8ec9fb9d53a499fd37dc (diff)
Merge pull request #110 from ElectroDeoxys/master
Split Home bank
Diffstat (limited to 'src/home/division.asm')
-rw-r--r--src/home/division.asm31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/home/division.asm b/src/home/division.asm
new file mode 100644
index 0000000..56bc651
--- /dev/null
+++ b/src/home/division.asm
@@ -0,0 +1,31 @@
+; divides BC by DE. Stores result in BC and stores remainder in HL
+DivideBCbyDE:
+ ld hl, $0000
+ rl c
+ rl b
+ ld a, $10
+.asm_3c63
+ ldh [hffb6], a
+ rl l
+ rl h
+ push hl
+ ld a, l
+ sub e
+ ld l, a
+ ld a, h
+ sbc d
+ ccf
+ jr nc, .asm_3c78
+ ld h, a
+ add sp, $2
+ scf
+ jr .asm_3c79
+.asm_3c78
+ pop hl
+.asm_3c79
+ rl c
+ rl b
+ ldh a, [hffb6]
+ dec a
+ jr nz, .asm_3c63
+ ret