summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Optimizing-assembly-code.md38
1 files changed, 4 insertions, 34 deletions
diff --git a/Optimizing-assembly-code.md b/Optimizing-assembly-code.md
index a6d0d65..93fa03a 100644
--- a/Optimizing-assembly-code.md
+++ b/Optimizing-assembly-code.md
@@ -24,7 +24,7 @@ WikiTI's advice fully applies here:
- [Rotate the bits of `a`](#rotate-the-bits-of-a)
- [Set `a` to some constant minus `a`](#set-a-to-some-constant-minus-a)
- [Set `a` to one constant or another depending on the carry flag](#set-a-to-one-constant-or-another-depending-on-the-carry-flag)
- - [Increment or decrement `a` depending on the carry flag](#increment-or-decrement-a-depending-on-the-carry-flag)
+ - [Increment or decrement `a` when the carry flag is set](#increment-or-decrement-a-when-the-carry-flag-is-set)
- [Divide `a` by 8 (shift `a` right 3 bits)](#divide-a-by-8-shift-a-right-3-bits)
- [Divide `a` by 16 (shift `a` right 4 bits)](#divide-a-by-16-shift-a-right-4-bits)
- [Set `a` to some value plus carry](#set-a-to-some-value-plus-carry)
@@ -314,19 +314,19 @@ If `CVAL` is 0 and `NCVAL` is 1 (i.e. set `a` to 0 if carry, or 1 if not carry),
```
-### Increment or decrement `a` depending on the carry flag
+### Increment or decrement `a` when the carry flag is set
Don't do:
```asm
- ; 3 bytes, 3 or 4 cycles
+ ; 3 bytes, 3 cycles
jr nc, .ok
inc a
.ok
```
```asm
- ; 3 bytes, 3 or 4 cycles
+ ; 3 bytes, 3 cycles
jr nc, .ok
dec a
.ok
@@ -342,36 +342,6 @@ But do:
sbc 0 ; 2 bytes, 2 cycles
```
-And don't do:
-
-```asm
- ; 3 bytes, 3 or 4 cycles
- jr c, .ok
- inc a
-.ok
-```
-
-```asm
- ; 3 bytes, 3 or 4 cycles
- jr c, .ok
- dec a
-.ok
-```
-
-But do:
-
-```asm
- ; 3 bytes, 3 cycles
- ccf
- adc 0
-```
-
-```asm
- ; 3 bytes, 3 cycles
- ccf
- sbc 0
-```
-
### Divide `a` by 8 (shift `a` right 3 bits)