From 60b598504c3f1663607f67153b5c385b35d581ed Mon Sep 17 00:00:00 2001 From: Rangi Date: Thu, 26 Nov 2020 13:22:29 -0500 Subject: Formatting --- Optimizing-assembly-code.md | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/Optimizing-assembly-code.md b/Optimizing-assembly-code.md index 791c7a6..cfeb403 100644 --- a/Optimizing-assembly-code.md +++ b/Optimizing-assembly-code.md @@ -182,20 +182,7 @@ The exception is if you need to set the zero flag when the operation results in 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 -``` - -And don't do: - -```asm -; 26 bytes, 26 cycles + ; 26 bytes, 26 cycles rept 8 rra rl b @@ -206,7 +193,7 @@ endr And don't do: ```asm -; 17 bytes, 17 cycles + ; 17 bytes, 17 cycles ld b, a rlca rlca @@ -226,7 +213,7 @@ And don't do: But do: ```asm -; 15 bytes, 15 cycles + ; 15 bytes, 15 cycles ld b, a rlca rlca @@ -241,6 +228,20 @@ But do: rrca ``` +Or if you really want to optimize for size over speed, then 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 +``` + + ### Set `a` to some constant minus `a` Don't do: -- cgit v1.2.3