From 985d56ca5a6bc836cf73cd3e2a4614afedb10f25 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Tue, 23 Jul 2019 22:59:10 -0400 Subject: [PATCH] core: preserve A in cpHLDE --- kernel/core.asm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/kernel/core.asm b/kernel/core.asm index 80ca9af..9259aaa 100644 --- a/kernel/core.asm +++ b/kernel/core.asm @@ -84,13 +84,22 @@ subHL: ; Compare HL with DE and sets Z and C in the same way as a regular cp X where ; HL is A and DE is X. +; A is preserved through some register hocus pocus: having cpHLDE destroying +; A bit me too many times. cpHLDE: + push bc + ld b, a ; preserve A ld a, h cp d - ret nz ; if not equal, flags are correct + jr nz, .end ; if not equal, flags are correct ld a, l cp e - ret ; flags are correct + ; flags are correct +.end: + ; restore A but don't touch flags + ld a, b + pop bc + ret ; Write the contents of HL in (DE) writeHLinDE: