diff options
| author | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-11-26 13:22:29 -0500 |
|---|---|---|
| committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-11-26 13:22:29 -0500 |
| commit | 60b598504c3f1663607f67153b5c385b35d581ed (patch) | |
| tree | 45596b459aee22ae53473c47f04b9124ddf72ef6 /Optimizing-assembly-code.md | |
| parent | 48d8503814af147bf844b6a6ae77e62e69204ee6 (diff) | |
Formatting
Diffstat (limited to 'Optimizing-assembly-code.md')
| -rw-r--r-- | Optimizing-assembly-code.md | 33 |
1 files 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: |
