4 notes: .ds 16 ; 0x00 .. 0x0f
9 .even ; make next two bytes word-aligned
16 .even ; SP must be aligned? (sdcc does it)
19 ; aliases for memory locations:
27 ; cycle count (worst-case)
30 ; sample: 115 + 4*g + 2*mod3 = 495
37 ;TODO: 0x0000 must be NOP for autocalib routine
38 ;TODO: move some init stuff here (space for 15 instr.)
50 ADD mod3lo, a ; mod3lo = hi+lo
58 AND a, #0xf ; (mod3lo>>4)
59 XCH mod3lo ; a=mod3lo, mod3lo=mod3lo>>4
60 AND a, #0xF ; a=mod3lo&0xf, mod3lo=mod3lo>>4
61 ADD a, mod3lo ; (mod3lo & 0xF)
65 AND a, #0x3 ; a = (mod3lo & 0x3)
67 SR mod3lo ; (mod3lo >> 2)
71 AND a, #0x3 ; a = (mod3lo & 0x3)
73 SR mod3lo ; (mod3lo >> 2)
82 ; notes_ix_hi = always 0
95 ; note: LSB of result (mul0) is not needed for our purposes
169 ; AUTO_INIT_SYSCLOCK() -- 4mhz
170 ; AUTO_CALIBRATE_SYSCLOCK() -- move away w/ goto
171 ; ??: setup fuses (romlocation 0x3ff)
173 ; setup timer2, timer16
178 ;rom is not mmapped; must load into ram first
203 ;TODO: setup mcu, timer16, ...
204 ;TODO: freepdk calibration routine
207 ;TODO: test i2==0x78 to enter halt()
212 ;TODO: send pwm data to timer2
214 MOV a, i2; "mov mem,mem"
215 MOV n, a; does not exist
235 MOV tmp_1, a ; fresh tmp_1:
240 OR a, tmp_1 ; tmp_1 done.
268 MOV tmp_1, a ; a saved in tmp_1; fresh a
270 ; shift-divide by six
271 ; note: i2 is max 0x78; so a will <= 20. (breaks vor values >=128)
284 AND a, tmp_1 ; a restored from tmp_1
307 MOV tmp_1, a ; a saved in tmp_1; fresh a
309 ; shift-divide by ten
310 ; note: i2 is max 0x78; so a will <= 12.
323 AND a, tmp_1 ; a restored from tmp_1
329 ; next sample is now ready.