fix IDXM'ing of the wrong notes
turns out, set1 M.n can only be used with 4-bit memory addresses, but
those are used by the notes array. supplying a 5-bit address (0x16 in
our case) causes it to be silently truncated (to 0x06, which
incidentally already has the modified bit set, so no change was
visible). this does not appear to be mentioned in the datasheet, but the
free-pdk instruction set documentation notes the allowed length of the
memory address.
even though this introduces two additional cycles per g(), the totoal
cycle count estimation is still (as) accurate, because we overestimated
the multiplication cycles by the same amount (0x9d is most "expensive"
number, takes 55 cycles).
for debugging this, ucsim (distributed with sdcc) was very helpful. the
setup looked like this:
- interrupt and timers not supported, so call interrupt() in a loop after init()
- disable the t1sn intrq check and s/reti/ret/i, since we are now
calling interrupt() directly
- remove ENGINT instruction, as it halts ucsim ("invalid instruction")
- in the OSEG (ram), add a new variable `simif: .ds 1 ;0x18`
- to output a byte to a file, write 'w' to simif, then the byte to send.
mov a, #'w'
mov simif, a
mov a, the_value
mov simif, a
- run the debugger for a few seconds, then ^C to quit:
spdk -Pt PDK13 -I if='ram[0x18],out='/tmp/out.bin -g bsv.ihx
- recreate the same screnario with bsv.c (e.g. fakeasm) using putchar()
- vimdiff each <(<$FILE head -
c131072 | xxd | sed 's/^[0-9a-f]://' | uniq -c)