typedef unsigned char u8; u8 i0, i1, i2; //MEM u8 acc; //ACC u8 notes[] = { 0x84, 0x9d, 0xb0, 0x69, 0x9d, 0x84, 0x69, 0x58, 0x75, 0x8c, 0xb0, 0x69, 0x8c, 0x75, 0x69, 0x58 }; void g(u8 t){ u8 notes_ix = t & 0x7; if(3&i2) notes_ix += 8; u8 result = ((i1<<8|i0)*notes[notes_ix])>>8; // keep hi byte acc = result; } void main(void){ i0 = i1 = i2 = 0; // clear i0 // clear i1 // clear i2 for(;;) { u8 sample; u8 n = i2<<2 | i1>>6; //MEM // mov n, i2 // sl n // sl n // mov acc, i1 // swap acc // and acc, 0xf // sr acc // sr acc // or n, acc g(n); //^TODO acc >>= 4; // swap acc acc &= 1; // and acc, 0x1 sample = acc; // mov sample, acc { u8 tmp; tmp = i2<<3 | i1>>5; tmp ^= n; g(tmp); //^TODO } //tmp acc >>= 1; // sr acc acc &= i2; // and acc, i2 acc >>= 1; // sr acc acc &= 3; // and acc, 3 sample += acc; // add sample, acc { u8 tmp2; tmp2 = (i2<<5|i1>>3)%3; tmp2 += n; g(tmp2); //^TODO } //tmp2 acc >>= 2; // sr acc // sr acc { u8 tmp1 = i2/6; acc &= tmp1; //^TODO } //tmp1 acc &= 3; // and acc, 3 sample += acc; // add sample, acc { u8 tmp2 = n; { u8 tmp3 = (i2<<6|i1>>2)%3; tmp2 -= tmp3; } // tmp3 tmp2 += 8; g(tmp2); } //tmp2 acc >>= 1; { u8 tmp1 = i2/10; acc &= tmp1; } //tmp1 acc &= 3; sample += acc; putchar(sample<<4); i0++; i1 += !i0; i2 += !i1 && !i0; } }