From 10b24652123a561282f8e77f6352cbef48de4d61 Mon Sep 17 00:00:00 2001 From: Rangi Date: Thu, 26 Nov 2020 14:33:41 -0500 Subject: GF's bad example --- Optimizing-assembly-code.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'Optimizing-assembly-code.md') diff --git a/Optimizing-assembly-code.md b/Optimizing-assembly-code.md index e2afc6f..8739c9b 100644 --- a/Optimizing-assembly-code.md +++ b/Optimizing-assembly-code.md @@ -228,11 +228,24 @@ But do: rrca ``` -Or if you really want to optimize for size over speed, then do: +Or if you really want to optimize for size over speed, then don't do: + +```asm + ; 10 bytes, 59 cycles + ld bc, 8 ; lb bc, 0, 8 +.loop + rra + rl b + dec c + jr nz, .loop + ld a, b +``` + +But do: ```asm ; 8 bytes, 50 cycles - ld b, $01 ; loop finishes once this 1 shifts to carry + ld b, 1 .loop rra rl b -- cgit v1.2.3