]> git.gir.st - Chiptunes-pms150c.git/commit - bsv.asm
fix IDXM'ing of the wrong notes
authorTobias Girstmair <tobi@isticktoit.net>
Fri, 30 Apr 2021 17:10:28 +0000 (19:10 +0200)
committerTobias Girstmair <tobi@isticktoit.net>
Fri, 30 Apr 2021 17:14:04 +0000 (19:14 +0200)
commit02a29960244b413ce39803d210a323675a63b2ad
tree824ac2ab488894e3996d22ed0a570983d83a206e
parentae0b6e4973974f228adafc06c0d2c0cceb37180c
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)
bsv.asm
Imprint / Impressum