EXAPUNKS

EXAPUNKS

View Stats:
Why "COPY 0 T" is making a difference in this code?
I was trying to solve "Mitsuzen HD-10 Visual Cortex" and I came up with this:


LINK 800
REPL WORKER
LINK 1
LINK 3
MARK RECEIVE
COPY 0 X
ADDI X M X
ADDI X M X
ADDI X M X
MULI X 5 X
SUBI X 75 #NERV
JUMP RECEIVE

MARK WORKER
LINK -3
LINK -3
REPL SEND
LINK 3
REPL SEND
LINK 3
MARK SEND
TEST #NERV > -55
ADDI T X X
LINK 1
TEST #NERV > -55
ADDI T X X
LINK 1
TEST #NERV > -55
ADDI T X M
COPY 0 X
LINK -1
LINK -1
JUMP SEND

the code above sometimes gives the correct answer, sometimes it doesn't.
Having no idea why, I randomly tried adding "COPY 0 T" to the code, and now suddenly it passes all the tests...

LINK 800
REPL WORKER
LINK 1
LINK 3
MARK RECEIVE
COPY 0 X
ADDI X M X
ADDI X M X
ADDI X M X
MULI X 5 X
SUBI X 75 #NERV
JUMP RECEIVE


MARK WORKER
LINK -3
LINK -3
REPL SEND
LINK 3
REPL SEND
LINK 3
MARK SEND
TEST #NERV > -55
ADDI T X X
LINK 1
TEST #NERV > -55
ADDI T X X
LINK 1
TEST #NERV > -55
ADDI T X M
COPY 0 X
COPY 0 T
LINK -1
LINK -1
JUMP SEND

What I don't understand is, the first line after "JUMP SEND" is "TEST #NERV > -55" so T is going to get a new value anyway, so why does it makes a difference if I have that "COPY 0 T" before the jump?
I can't understand this, and I'm probably missing something very obvious... x_x
< >
Showing 1-2 of 2 comments
By sending to #NERV, you change all values. Without the "COPY 0 T", the first worker is reading an old value, but accounting it for the new round. As you just need to pass time, a "NOOP" works as well.

(Why did you insert a "COPY 0 T"? :D )
Originally posted by Zyro:
By sending to #NERV, you change all values. Without the "COPY 0 T", the first worker is reading an old value, but accounting it for the new round. As you just need to pass time, a "NOOP" works as well.
Ah, thank you! I couldn't understand this for the life of me xD

(Why did you insert a "COPY 0 T"? :D )
Everything I wrote seemed simple and logical, so I guess I started doubting the registers or my understanding of them xD
(only after writing it and seeing it solving the problem I realized it was nonsense and it shouldn't have solved anything lul)
< >
Showing 1-2 of 2 comments
Per page: 1530 50