From b51316eddeb231d7e7ff8d217e61e8d87942d51c Mon Sep 17 00:00:00 2001 From: Eldred Habert Date: Mon, 6 Jan 2020 11:27:48 +0100 Subject: [PATCH] Fix `MultiplyNumbers` macro It used to shift the number left 11 times, not multiply it. --- gbasmdev.tex | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gbasmdev.tex b/gbasmdev.tex index f8f35bd..05322c9 100644 --- a/gbasmdev.tex +++ b/gbasmdev.tex @@ -376,10 +376,11 @@ \section{Loops} push bc ; lets us use B register ; without messing up existing data, ; as it is restored before we return + ld c, a - ld b, 11 ; the number of times we loop + ld b, 10 ; the number of times we loop .loop: - add a ; add A onto itself + add c ; add the original value (in C) onto A dec b ; decrease loop counter jr nz, .loop ; if didn't reach zero, go back ; If we got here, the loop is finished @@ -507,10 +508,10 @@ \section{Compile time operations} \begin{code} MultiplyNumbers: MACRO - ld a, \1 - ld b, \2 + ld bc, (\2) << 8 | (\1) + xor a .loop\@: - add a + add c dec b jr nz, .loop\@ \end{code}