new version
authorTobias Girstmair <tobi@isticktoit.net>
Thu, 4 Mar 2021 12:27:09 +0000 (13:27 +0100)
committerTobias Girstmair <tobi@isticktoit.net>
Thu, 4 Mar 2021 12:36:03 +0000 (13:36 +0100)
div6 was prototyped with this program:

typedef unsigned char u8;
int main(void) {
for (int i = 0; i <= 0x78; i++) {
u8 real = i/6;
u8 test = i;

test >>= 1;
test += i;

test >>= 1;
test += 0;

test >>= 1;
test += i;

test >>= 1;
test += 0;

test >>= 1;
test += i;

test >>= 1;
test += 0;

test >>= 1;
test >>= 1;

if (test != real)
printf ("%hhd/6 == %hhd != %hhd\n", i, real, test);
}
return 0;
}

bsv.c

diff --git a/bsv.c b/bsv.c
index 81095016fd2dfa1a950349d8d785ce53e4353b96..8ce4b42801dc782fc48ddc419dccbf1b34507e4e 100644 (file)
--- a/bsv.c
+++ b/bsv.c
@@ -70,31 +70,18 @@ void main(void){
                MOV     (tmp_1, acc) // acc saved in tmp_1; fresh acc
                MOV     (acc, i2)
                // shift-divide by six
                MOV     (tmp_1, acc) // acc saved in tmp_1; fresh acc
                MOV     (acc, i2)
                // shift-divide by six
-               // note: i2 is max 0x78; so acc will <= 20.
-
+               // note: i2 is max 0x78; so acc will <= 20. (breaks vor values >=128)
                 SR     (acc)
                ADD     (acc, i2)
                 SR     (acc)
                ADD     (acc, i2)
-
                SR      (acc)
                SR      (acc)
-                //ADD acc, 0
-
                 SR     (acc)
                ADD     (acc, i2)
                 SR     (acc)
                ADD     (acc, i2)
-
                SR      (acc)
                SR      (acc)
-                //ADD acc, 0
-
                 SR     (acc)
                ADD     (acc, i2)
                 SR     (acc)
                ADD     (acc, i2)
-
                SR      (acc)
                SR      (acc)
-                //ADD acc, 0
-
                SR      (acc)
                SR      (acc)
-                //ADD acc, 0
                SR      (acc)
                SR      (acc)
-                //ADD acc, 0
-
                // end divide by six
                AND     (acc, tmp_1) // acc restored from tmp_1
                AND     (acc, 3)
                // end divide by six
                AND     (acc, tmp_1) // acc restored from tmp_1
                AND     (acc, 3)
Imprint / Impressum