The aim of z80nops, is to compute the amount of nops takes a (very) simple z80 routine. There are lots of limitations to this project:
- does not take into account insttructions having 2 durations (a conditionnal jump, for example)
- does not take into account instructions whose durations depends on a specific register (ldir for example)
- does not take into account branching possibilities and sub-functions (no tree of duration are computed)
However, these limitations could be removed if necessary
git clone https://github.com/cpcsdk/z80tonops.git
mkdir build && cd build
cmake ../z80tonops/src
make && sudo make install
The purpose of this mode is to integrate well with editors.
echo "
ld bc, 0xbc00 + 2
out (c), c
inc b
ld hl, XXX
out (c), h
dec b
inc c
out (c), c
inc b
out (c), l " | z80tonops
which outputs
; START COUNTING
ld bc, 0xbc00 + 2 ; 3 nops
out (c), c ; 4 nops
inc b ; 1 nops
ld hl, XXX ; 3 nops
out (c), h ; 4 nops
dec b ; 1 nops
inc c ; 1 nops
out (c), c ; 4 nops
inc b ; 1 nops
out (c), l ; 4 nops
; STOP COUNTING
; Total number of nops = 26
z80tonops test.z80
which outputs
; START COUNTING
ld bc, 0xbc00 + 2 ; 3 nops
out (c), c ; 4 nops
inc b ; 1 nops
ld hl, XXX ; 3 nops
out (c), h ; 4 nops
dec b ; 1 nops
inc c ; 1 nops
out (c), c ; 4 nops
inc b ; 1 nops
out (c), l ; 4 nops
; STOP COUNTING
; Total number of nops = 26
In visual mode, selection of the code of interest.
Then [ESC]:!z80tonops
to replace the lines by a version appended with the number of nops
- Tackle the limitations
- Better integration with vim (Add/remove nops annoations, compare manually annotated nops with computed ones, ...)