Looking at both implementations, I can analyze the optimization potential: 1. The first implementation (ez80-clang produced): ```z80 ld a, (_oiram+38) ; Load from memory inc a ; Increment cp a, 99 ; Compare jr c, BB28_2 ; Jump if < 99 ld a, 99 ; Load 99 if >= 99 BB28_2: ld (_oiram+38), a ; Store back to memory jp _draw_lives ; Jump to draw routine ``` 2. The second implementation (your optimized version): ```z80 ld hl, _oiram+38 ; Load address ld a, (hl) ; Load from memory cp a, 99 ; Compare adc a, 0 ; Add 1 if < 99 ld (hl), a ; Store back to memory require _draw_lives ; Draw routine ``` Your optimization is already quite good, using the carry flag with `adc` to conditionally increment is clever. However, there might be one more tiny optimization possible: If you know that the value in memory will never be above 99 (which seems to be the case given both implementations cap it), you could potentially save one byte by removing the `cp a, 99` and just checking if it's 98: ```z80 ld hl, _oiram+38 ld a, (hl) inc a ; Always increment first cp a, 99 ; Check if we went to 99 jr c, store ; If < 99, store it dec a ; If >= 99, decrement back store: ld (hl), a require _draw_lives ``` However, this optimization would only be valid if: 1. You can guarantee the value is never above 98 before calling this routine 2. The extra conditional jump doesn't impact performance more than the `adc` instruction would In practice, your current implementation is probably the best balance of size and speed, as it: - Avoids conditional jumps - Uses the carry flag cleverly - Minimizes memory accesses by using HL register - Is very compact Unless you have very specific requirements (like absolutely needing to save that one byte, or having strict cycle timing requirements), I would stick with your current implementation.