]>
git.gir.st - Chiptunes.git/blob - foo.c
1bc2f0476c94e1b3a9fd183c1583d11946bcabdf
3 typedef unsigned char u8
;
6 0x84, 0x9d, 0xb0, 0x69, 0x9d, 0x84, 0x69, 0x58,
7 0x75, 0x8c, 0xb0, 0x69, 0x8c, 0x75, 0x69, 0x58
19 u8 t
;/*==Ml*/ //r26 (Xlo)
20 u8 x
;/*==Mh*/ //r27 (Xhi)
23 /*fakestack_l*/ //r30 (Zlo)
24 /*fakestack_h*/ //r31 (Zhi)
25 #define Mh x //mod3 vars
27 //http://homepage.divms.uiowa.edu/~jones/bcd/mod.shtml
33 ADC (Mh
, zero
, carry
) //Mh only holds the carry bit
60 // tempvars: `x` and `_`
70 //TODO: directly load address to mul_* routine and jump to it?
71 ;static void* mul_jmptable
[] = {
72 &&mul_84
, &&mul_9d
, &&mul_b0
, &&mul_69
, &&mul_9d
, &&mul_84
, &&mul_69
, &&mul_58
,
73 &&mul_75
, &&mul_8c
, &&mul_b0
, &&mul_69
, &&mul_8c
, &&mul_75
, &&mul_69
, &&mul_58
82 goto *t_
; //GNU extension simulates indirect jump
86 ADD Xlo, t ; 16 bit value; advance by 2*u8
87 LDI Xhi==t, data_hi <--this won't work, need t afterwards
97 /*MOV X_hi==x, data_hi _
98 MOV X_lo==t, data_lo \_ this won't
99 ADD X_lo, t _/ work! XXX
110 //sorted by ocurrence, then longest cycle count first
125 mul_58
: // 0101 1000 (24cy)
148 mul_69
: // 0110 1001 (26cy)
173 mul_75
: // 0111 0101 (28cy)
200 mul_84
: // 1000 0100 (22cy)
221 mul_8c
: // 1000 1100 (24cy)
244 mul_9d
: // 1001 1101 (28cy)
271 mul_b0
: // 1011 0000 (22cy)
294 LSR (a2
) //final shift is a common operation for all
301 RET
//TODO: replace CALL/RET with IJMP?
455 putchar(acc
<<4); //TODO
458 ADC (i2
, zero
, !i0
&&!i1
)
459 ADC (i3
, zero
, !i0
&&!i1
&&!i2
)