new version
authorTobias Girstmair <tobi@isticktoit.net>
Thu, 4 Mar 2021 01:23:59 +0000 (02:23 +0100)
committerTobias Girstmair <tobi@isticktoit.net>
Thu, 4 Mar 2021 01:23:59 +0000 (02:23 +0100)
bsv.c
fakeasm.h

diff --git a/bsv.c b/bsv.c
index 715cdd5661753befcecfdb8e39ad9058b4ca5157..d1fe79513e9049aa2f43b78300d845550345b0e5 100644 (file)
--- a/bsv.c
+++ b/bsv.c
@@ -12,8 +12,8 @@ u8 notes[] = {
        0x75, 0x8c, 0xb0, 0x69, 0x8c, 0x75, 0x69, 0x58
 };
 
-void g(u8 t){
-       u8 notes_ix = t & 0x7;
+void g(void){
+       u8 notes_ix = acc & 0x7;
        if(3&i2)
                notes_ix += 8;
        u8 result = ((i1<<8|i0)*notes[notes_ix])>>8;  // keep hi byte
@@ -35,17 +35,16 @@ void main(void){
                SR      (acc)
                OR      (n, acc)
 
-               g(n);
-               //^TODO
+               MOV     (acc, n)
+               CALL    (g)
                SWAP    (acc)
                AND     (acc, 0x1)
                MOV     (sample, acc)
 
-               { u8 tmp;
-                 tmp = i2<<3 | i1>>5;
-                 tmp ^= n;
-               g(tmp);
-               //^TODO
+               { u8 tmp = i2<<3 | i1>>5;//TODO
+               MOV     (acc, tmp)
+               XOR     (acc, n)
+               CALL    (g)
                } //tmp
                SR      (acc)
                AND     (acc, i2)
@@ -53,11 +52,10 @@ void main(void){
                AND     (acc, 3)
                ADD     (sample, acc)
 
-               { u8 tmp2;
-                 tmp2 = (i2<<5|i1>>3)%3;
-                 tmp2 += n;
-               g(tmp2);
-               //^TODO
+               { u8 tmp2 = (i2<<5|i1>>3)%3;//TODO
+               MOV     (acc, tmp2)
+               ADD     (acc, n)
+               CALL    (g)
                } //tmp2
                SR      (acc)
                SR      (acc)
@@ -67,13 +65,12 @@ void main(void){
                AND     (acc, 3)
                ADD     (sample, acc)
 
-               { u8 tmp2 = n;
-                 { u8 tmp3 = (i2<<6|i1>>2)%3;
-                   tmp2 -= tmp3;
-                 } // tmp3
-                 tmp2 += 8;
-               g(tmp2);
-               } //tmp2
+               MOV     (acc, n)
+               { u8 tmp3 = (i2<<6|i1>>2)%3;
+                 SUB   (acc, tmp3)
+               } // tmp3
+               ADD     (acc, 8)
+               CALL    (g)
                SR      (acc)
                { u8 tmp1 = i2/10;
                AND     (acc, tmp1)
index a42a3735fd31f36418adc92a8dff26d05fc8c3e0..3b1c4045e3508c23ae6c81e61cb0210d4de6782c 100644 (file)
--- a/fakeasm.h
+++ b/fakeasm.h
@@ -11,3 +11,6 @@ int flag_c = 0;
 #define ADD(dst, src)  dst += src; flag_c = (src+dst>0xff); flag_z = (dst==0);
 #define INC(dst)       dst += 1; flag_c = flag_z = (dst==0);
 #define ADDC0(dst)     dst += flag_c; flag_c = flag_z = (dst==0);
+#define CALL(addr)     addr();
+#define XOR(dst, src)  dst ^= src; flag_z = (dst==0);
+#define SUB(dst, src)  flag_c = (src > dst); dst -= src; flag_z = (dst==0);
Imprint / Impressum