math: Added 16 bit sub
authorLukas Krickl <lukas@krickl.dev>
Sun, 1 Feb 2026 07:38:06 +0000 (08:38 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sun, 1 Feb 2026 07:38:06 +0000 (08:38 +0100)
src/math.s

index 22e0f6474d9314a763962045a81bfb848ffba08d..6a612eed5bd551627f499c38a0b1ec906bbb921c 100644 (file)
@@ -52,4 +52,19 @@ m16_add:
        ;       returns:
        ;               m16_a: m16_a - m16_b
 m16_sub:
+       ld a, [m16_b]
+       ld b, a
+       ld a, [m16_a]
+       
+       ; low is stored
+       sub a, b
+       ld [m16_a], a
+
+       ld a, [m16_b+1]
+       ld b, a
+       ld a, [m16_a+1]
+
+       ; high + carry stored
+       sbc a, b
+       ld [m16_a+1], a
        ret