From: Lukas Krickl Date: Sun, 1 Feb 2026 07:38:06 +0000 (+0100) Subject: math: Added 16 bit sub X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=9b8e9767f1a20190412bcdb5381dd6aa24a9fffd;p=gbrg%2F.git math: Added 16 bit sub --- diff --git a/src/math.s b/src/math.s index 22e0f64..6a612ee 100644 --- a/src/math.s +++ b/src/math.s @@ -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