From 00c059e5b18bf9d0eb9d1d58860233f38c106ad5 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Tue, 15 Nov 2022 00:57:57 +0100 Subject: [PATCH] adding cx16/adpcm example --- .../prog8/codegen/intermediate/IRCodeGen.kt | 3 + docs/source/todo.rst | 3 + examples/cx16/adpcm-mono.bin | Bin 0 -> 24576 bytes examples/cx16/adpcm.p8 | 129 ++++++++++++++++++ examples/test.p8 | 16 +-- 5 files changed, 138 insertions(+), 13 deletions(-) create mode 100644 examples/cx16/adpcm-mono.bin create mode 100644 examples/cx16/adpcm.p8 diff --git a/codeGenIntermediate/src/prog8/codegen/intermediate/IRCodeGen.kt b/codeGenIntermediate/src/prog8/codegen/intermediate/IRCodeGen.kt index 74be1faf9..57f563571 100644 --- a/codeGenIntermediate/src/prog8/codegen/intermediate/IRCodeGen.kt +++ b/codeGenIntermediate/src/prog8/codegen/intermediate/IRCodeGen.kt @@ -1121,6 +1121,9 @@ class IRCodeGen( is PtIncludeBinary -> { irBlock += IRInlineBinaryChunk(null, readBinaryData(child), null) } + is PtLabel -> { + TODO("allow label inside block scope ${child.name}") + } else -> TODO("weird child node $child") } } diff --git a/docs/source/todo.rst b/docs/source/todo.rst index b7e24ddf4..a7563e567 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -3,6 +3,9 @@ TODO For next release ^^^^^^^^^^^^^^^^ +- fix 6502 optimizer hanging on uword xx = 100 :: uword yy = xx / 256 +- why is func(x&15) fast, but func(x>>4) using stack eval for the arg? +- ir/vm: allow label in block scope - 6502 codegen: make it possible to use cpu opcodes such as 'nop' as variable names by prefixing all asm vars with something such as ``p8v_``? Or not worth it (most 3 letter opcodes as variables are nonsensical anyway) then we can get rid of the instruction lists in the machinedefinitions as well. This is already no problem at all in the IR codegen. - create BSS section in output program and put StStaticVariables in there with bss=true. Don't forget to add init code to zero out everything that was put in bss. If array in bss->only zero ONCE! So requires self-modifying code diff --git a/examples/cx16/adpcm-mono.bin b/examples/cx16/adpcm-mono.bin new file mode 100644 index 0000000000000000000000000000000000000000..33e5e7a009450ffef0e9222fd190581f0beeede8 GIT binary patch literal 24576 zcmWiV0KRu+Fjbtd7VOM z_XfJ>b@?%SuOvG}vJ)cN36Y#YBs&z_p~ZH>)CqLR4?0btGYz4$OK9f~(3xFm=j=k5 z*$vP=bAA8yU)G~X&-3~5{(cGrz<>Vv^OgTg5wRW@T0AZa?um*g4(byNxq3jx5NL{c zB9PBe>c&nav7c?RPA-Of+;gY;NxNm%sXJ&tpEORLkp1#8!8T6pngVPWYpKVet2**+ z%2s48z_&n#yu*}w=l~@58 z7^vGFe1njgYvWQ5zti6WTc-Tkh5lRWX#oP-wE*HL-K+N zj6WPDUZ>4ec-|af?8g`-yM21U^Ny=rg(I0(c7d@zV%$o&qsM(0KXV`^iV;h3gTl^? zLY_}RASv$FduRF|!(`oFSO!BE^%bFmmhtG}EMf4K^Iv3{@Vf@5cBd3!2z5HXCE8e3 z27CXB%V6re?Lk1D&;q;E@i!pmCj7A94zm04WD%ePHtW}GwhYiV3<%u};a$Z&JZKF) z{2DzEpt9qT5JoEQ;qoA4=a<{)FqeuwJVZFH*JpZu1^^kSx<6z)2CQoVV5uD1qjJ@} z{f`(W$ZEB&wr56io*^RCF8FGH<8nArQWi#&9?#PqU7&fAy6LfQW8KD|J0S=td$nG+ z$dJbUaGjYKk(upP$OEhM4=9hiGf?*p@)R~3!^7_C?#W%CqK>kGpOay$Ynp{Ky;)*o z=N+qA;e?Wf@Lam)oeP`PN@~HD;`_R?81r#Oud|>BlqIk$aX>0&ovvhd5tg?=kmq6@ z^aD7mssvqXaRjb*nK?Bjuj2vCfL!0~uOy#n*HP#ljMpv#4PrwwQ8(9ej#|*2;yl17 z0tDTooVoqCT`Ibz_me;U1(2}b#7{VXTOnPVAL2vJ9*D-}J<&g6?d065PSi2R*q ztzeV>-GoROZK<8h7HDwyOdHSh)-a#4_*)*G0Od)kUF15Xa-|V^6-d7k7Q;8a435;p z8QbSam>@gp%C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x=6gTuuJWCjZ-@kT&n+o2S+aGJgCq1qPHTnA z7sEw8JS(_)tw3{Y5Y;zTHh4E=u@`H%@%@kNiGXjsfOV)*tC^}Od2=07 zu8H>+5aXD5`(>f~VaY~`V4z5v2fCTCh~oOZ>|A?Zpdm-zXL(GXH)BF2(Vroc zb3xm_+fr+ac;DmTPO%J@^vz}0Ka+^*T4AT4S%sZ9%P5uZdEUvlCOgxOV~vdD>7=R8 wFpMPr>= 4 + adpcm.decode_nibble(nibble) + txt.print_w(adpcm.predict as word) + txt.spc() + nibblesptr++ + } + } + + repeat { + } + } + +; sub irqhandler() { +; cx16.vpoke(1, $fa00, 255) +; +; uword @zp sample = peekw(nibbles) +; adpcm.init(sample, nibbles[2]) +; +; ubyte @zp idx = 4 +; while idx<100 { +; ubyte @zp nibble = nibbles[idx] +; adpcm.decode_nibble(nibble & 15) +; sample = adpcm.predict +; nibble >>= 4 +; adpcm.decode_nibble(nibble) +; sample = adpcm.predict +; idx++ +; } +; +; cx16.vpoke(1, $fa00,0) +; } + +adpcm_data: + %asmbinary "adpcm-mono.bin" +adpcm_data_end: + + ubyte[256] nibbles = [216, 227, 59, 0, 32, 2, 186, 139, 24, 34, 84, 115, 19, 185, 173, 8, 0, 56, 162, + 169, 144, 113, 55, 130, 186, 12, 33, 144, 10, 136, 10, 129, 41, 66, 210, 207, + 9, 0, 153, 129, 185, 173, 155, 0, 37, 162, 191, 27, 36, 129, 144, 137, 82, 18, + 87, 18, 152, 153, 136, 0, 32, 23, 0, 40, 24, 117, 19, 202, 138, 8, 176, 171, + 24, 131, 234, 9, 32, 39, 160, 10, 153, 33, 52, 209, 137, 200, 73, 33, 233, 155, + 136, 66, 146, 8, 152, 56, 131, 113, 23, 168, 169, 185, 9, 160, 65, 37, 49, 22, + 64, 68, 168, 138, 153, 1, 171, 88, 35, 25, 65, 1, 176, 173, 185, 175, 168, 154, + 153, 205, 138, 144, 152, 154, 204, 43, 53, 51, 35, 154, 184, 96, 71, 34, 152, + 172, 138, 160, 9, 24, 16, 204, 88, 48, 54, 160, 172, 152, 65, 132, 168, 48, 4, + 0, 190, 9, 161, 155, 218, 139, 154, 185, 207, 9, 50, 130, 184, 252, 155, 24, + 53, 144, 172, 170, 88, 51, 1, 176, 173, 17, 40, 115, 129, 136, 200, 11, 70, + 129, 8, 0, 0, 48, 37, 160, 42, 35, 32, 17, 18, 220, 174, 170, 143, 9, 137, 160, + 171, 104, 4, 169, 154, 219, 142, 65, 129, 128, 168, 9, 69, 50, 130, 219, 128, + 138, 49, 52, 146, 237, 141, 50, 21, 8, 136, 8, 153, 35, 193, 170, 2, 169, 224, + 186, 170, 40, 253, 12, 17, 25] + +} + + +adpcm { + ubyte[] t_index = [ -1, -1, -1, -1, 2, 4, 6, 8, -1, -1, -1, -1, 2, 4, 6, 8] + uword[] t_step = [ + 7, 8, 9, 10, 11, 12, 13, 14, + 16, 17, 19, 21, 23, 25, 28, 31, + 34, 37, 41, 45, 50, 55, 60, 66, + 73, 80, 88, 97, 107, 118, 130, 143, + 157, 173, 190, 209, 230, 253, 279, 307, + 337, 371, 408, 449, 494, 544, 598, 658, + 724, 796, 876, 963, 1060, 1166, 1282, 1411, + 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, + 3327, 3660, 4026, 4428, 4871, 5358, 5894, 6484, + 7132, 7845, 8630, 9493, 10442, 11487, 12635, 13899, + 15289, 16818, 18500, 20350, 22385, 24623, 27086, 29794, + 32767] + + uword @zp predict + ubyte @zp index + uword @zp pstep + + sub init(uword startPredict, ubyte startIndex) { + predict = startPredict + index = startIndex + pstep = t_step[index] + } + + sub decode_nibble(ubyte nibble) { + word @zp difference = 0 + if nibble & 4 + difference += pstep + pstep >>= 1 + if nibble & 2 + difference += pstep + pstep >>= 1 + if nibble & 1 + difference += pstep + pstep >>= 1 + difference += pstep + if nibble & 8 + difference = -difference + predict += difference as uword + index += t_index[nibble] + if index & 128 + index = 0 + else if index > 88 + index = 88 + pstep = t_step[index] + } +} diff --git a/examples/test.p8 b/examples/test.p8 index fc357aac1..d292b9919 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -1,18 +1,8 @@ -%import textio -%zeropage basicsafe - main { sub start() { - uword[] @shared ptrs = [&x1, &x2, &start, 4242, 4242] - ubyte x1 - ubyte x2 - - txt.print_uwhex(ptrs[0], true) - txt.spc() - txt.print_uwhex(ptrs[1], true) - txt.spc() - txt.print_uwhex(ptrs[2], true) - txt.nl() + uword xx = 100 + uword yy = xx / 256 ; TODO hangs in optimizer for 6502 + yy++ } }