VLIWIS-0.2 solution for Fizzle-Bizzle v1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| init: A=IN1, JMP ired1 ; 0 | |
| B=B ; 1 | |
| emit2: OUT1=W, A=IN1, JMP ired1 ; 2 emit | |
| emit3: OUT1=W, A=IN1, JMP ired1 ; 3 emit | |
| B=B ; 4 | |
| emit5: OUT1=W, A=IN1, JMP ired1 ; 5 emit | |
| cont6: JMPF init ; 6 jump on !=5 (or !=3, depending on where arrival is from) | |
| rodd7: JMPT emit2, F=ZERO(A-B), B=2 ; 7 on entry: F=zero(A-7), B=10; jump on =7, test for =10 | |
| JMPF cont12, F=ZERO(A-B), B=12 ; 8 jump on =10, test for =2 | |
| OUT1=W, A=IN1, JMP ired1 ; 9 emit | |
| crem10: JMPF crem21, A=A/2, F=NEG() ; 10 jump on =0, test for odda | |
| OUT1=W, A=IN1, JMP ired1 ; 11 emit | |
| cont12: JMPT emit3, F=ZERO(A-B), B=3 ; 12 jump on =12, test for =2 | |
| JMPF cont6, F=ZERO(A-B) ; 13 jump on !=2, test for =3 | |
| emit14: OUT1=W, A=IN1, JMP ired1 ; 14 emit | |
| emit15: OUT1=W, A=IN1, JMP ired1 ; 15 emit | |
| ired1: W=A, B=175, F=NEG(0) ; 16 prepare for coarse reduction | |
| red1: A=A-B, F=NEG(), JMPF red1 ; 17 reduction1 loop | |
| A=A+B, B=35 ; 18 undo overshoot, prepare for finer reduction | |
| red2: A=A+B, F=NEG(), JMPT red2 ; 19 reduction2 loop | |
| A=A-B, F=ZERO(), B=10, JMP crem10; 20 undo overshoot, prepare for remainder check, prep for =10 test (both sides) | |
| ; check possible remainders | |
| crem21: JMPT rodd7, F=ZERO(A-B), B=7 ; 22 jump on odd, test for =10 (both sides), prep for =7 test (both sides) | |
| JMPT emit14, F=ZERO(A-B), B=14 ; 23 jump on =7, test for =10 | |
| JMPT emit15, F=ZERO(A-B), B=15 ; 24 jump on =10, test for =14 | |
| JMPT emit5, F=ZERO(A-B), B=5 ; 25 jump on =14, test for =15 | |
| JMPF cont6, F=ZERO(A-B) ; 26 jump on !=15, test for =5 | |
| OUT1=W, A=IN1, JMP ired1 ; 27 emit | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment