I've completed the "Sequence Counter" level of TIS-100, but this is horrendously inefficient. My cycle counts are at about twice the minimum possible according to the charts:
I'm not really as concerned about the other metrics.
I struggled to figure this one out. And there's definitely bits of my code which I know look suspicious, but I don't feel strong enough with the language yet to really spot how to make this execute fewer instructions.
Here's the problem description:
SEQUENCES ARE ZERO TERMINATED READ A SEQUENCE FROM IN WRITE THE SUM TO OUT.S WRITE THE LENGTH TO OUT.L
Most of my code are in three nodes:
TOP LEFT (IN)
START:
MOV UP, ACC
MOV ACC, DOWN
MOV ACC, DOWN
JNZ SEQ
MOV 0, RIGHT
MOV 0, RIGHT
JMP START
SEQ:
MOV 1, RIGHT
MOV 1, RIGHT
TOP RIGHT
START:
ADD LEFT
SAV
MOV 0, ACC
MOV LEFT, ACC
JEZ DONE
SWP
JMP START
DONE:
SWP
MOV ACC, DOWN
MOV 0, ACC
MIDDLE LEFT:
START:
ADD UP
SAV
MOV 0, ACC
MOV UP, ACC
JEZ DONE
SWP
JMP START
DONE:
SWP
MOV ACC, DOWN
MOV 0, ACC
MIDDLE RIGHT:
MOV UP, DOWN
BOTTOM LEFT (OUT.S)
MOV UP, DOWN
BOTTOM RIGHT (OUT.L)
MOV UP, DOWN
As I said, this works, but it's horribly inefficient. Cycle count is up to 485... but looks like it could be under 250.
Also, any tips on making this code more readable while still staying within the extreme character limits would be greatly appreciated.