new version
authorTobias Girstmair <tobi@isticktoit.net>
Fri, 5 Mar 2021 13:20:28 +0000 (14:20 +0100)
committerTobias Girstmair <tobi@isticktoit.net>
Fri, 5 Mar 2021 13:21:22 +0000 (14:21 +0100)
a1 and a2 had to be renamed, since the sdcc-assembler complains about
them (yes, i started working on the port to realasm already).

bsv.c

diff --git a/bsv.c b/bsv.c
index 12c1819772351fa94ecd7eafaade03a47b442f46..5fb6e83832b05a10c61f94a382b26f7a4a32e1b6 100644 (file)
--- a/bsv.c
+++ b/bsv.c
@@ -57,22 +57,82 @@ void g(void){
        SET1    (notes_ix, 3)           } // ix += 8 <=> ix |= 8
        IDXM    (acc, notes+notes_ix)
 
-       //unrolled: https://git.gir.st/Chiptunes.git/blob/f8e0502:/foo.S#l113
-       u8 a2 = 0; // can probably be overloaded onto mul3lo/hi
-       u8 a1 = 0; // -"-
-       u8 t  = acc; // note input (as returned by idxm)
-       for (u8 loop = 0; loop < 8; loop++) {
+       #define mul2 mod3hi
+       #define mul1 mod3lo
+       #define t tmp_1
+       MOV     (t, acc)
+       CLEAR   (mul2)
+       CLEAR   (mul1)
+       //1/8:
                SR      (t)
-               /*T1SN  FLAG.C (0x00.1)*/       if (!flag_c) // skip if carry set
-               goto skip;
+               /*T1SN  FLAG.C*/        if(!flag_c) {
+               goto    skip1;          }
                MOV     (acc, i0)
-               ADD     (a1, acc)
+               ADD     (mul1, acc)
                MOV     (acc, i1)
-               ADDC    (a2, acc)
-       skip:   SR      (a2)
-               SRC     (a1)
-       }
-       MOV     (acc, a1)
+               ADDC    (mul2, acc)
+       skip1:  SR      (mul2)
+               SRC     (mul1)
+       //2/8:
+               SR      (t)
+       skip2:  SR      (mul2)
+               SRC     (mul1)
+       //3/8:
+               SR      (t)
+               /*T1SN  FLAG.C*/        if(!flag_c) {
+               goto    skip3;          }
+               MOV     (acc, i0)
+               ADD     (mul1, acc)
+               MOV     (acc, i1)
+               ADDC    (mul2, acc)
+       skip3:  SR      (mul2)
+               SRC     (mul1)
+       //4/8:
+               SR      (t)
+               /*T1SN  FLAG.C*/        if(!flag_c) {
+               goto    skip4;          }
+               MOV     (acc, i0)
+               ADD     (mul1, acc)
+               MOV     (acc, i1)
+               ADDC    (mul2, acc)
+       skip4:  SR      (mul2)
+               SRC     (mul1)
+       //5/8:
+               SR      (t)
+               /*T1SN  FLAG.C*/        if(!flag_c) {
+               goto    skip5;          }
+               MOV     (acc, i0)
+               ADD     (mul1, acc)
+               MOV     (acc, i1)
+               ADDC    (mul2, acc)
+       skip5:  SR      (mul2)
+               SRC     (mul1)
+       //6/8:
+               SR      (t)
+               /*T1SN  FLAG.C*/        if(!flag_c) {
+               goto    skip6;          }
+               MOV     (acc, i0)
+               ADD     (mul1, acc)
+       skip6:
+               SRC     (mul1)
+       //7/8:
+               SR      (t)
+               /*T1SN  FLAG.C*/        if(!flag_c) {
+               goto    skip7;          }
+               MOV     (acc, i0)
+               ADD     (mul1, acc)
+       skip7:
+               SRC     (mul1)
+       //8/8:
+               SR      (t)
+               /*T1SN  FLAG.C*/        if(!flag_c) {
+               goto    skip8;          }
+               MOV     (acc, i0)
+               ADD     (mul1, acc)
+       skip8:
+               SRC     (mul1)
+
+       MOV     (acc, mul1)
        RET
 }
 void main(void){
Imprint / Impressum