[puzzle] Escape
kuroneko
Posts: 3,623
Given the listed code fragment, you have 4 longs (code, no data) to execute the instructions at pick and exit. After executing exit the task is done so you can safely execute the cogstop. Further limitations:
- the red coloured instructions are read-only and can't be changed
- cnt's shadow register is read-only (add cnt, #n|reg & Co are therefore invalid)
- the blue instructions are an example, they are unknown to you for the purpose of this exercise
DAT org 0
escape [COLOR="Red"]cogid cnt[/COLOR]
nop ' |
[COLOR="DarkOrange"]nop[/COLOR] ' |
[COLOR="DarkOrange"]nop[/COLOR] ' |
[COLOR="DarkOrange"]nop[/COLOR] ' | your code here
[COLOR="Red"]cogstop cnt[/COLOR]
pick [COLOR="Blue"]mov par, #42[/COLOR]
[COLOR="Red"]cogstop cnt[/COLOR]
exit [COLOR="Blue"]wrlong par, par[/COLOR]
[COLOR="Red"]cogstop cnt[/COLOR]
fit

Comments
DAT org 0 escape cogid cnt mov :i1, pick :i1 movs :i2, #exit :i2 jmp #:i1 cogstop cnt pick mov par, #42 cogstop cnt exit wrlong par, par cogstop cnt fitOR
DAT org 0 escape cogid cnt mov :i1, pick :i1 mov :i2, exit :i2 jmp #:i1 cogstop cnt pick mov par, #42 cogstop cnt exit wrlong par, par cogstop cnt fitDAT org 0 escape cogid cnt mov newcode, pick nop newcode nop jmp #exit cogstop cnt pick mov par, #42 cogstop cnt exit wrlong par, par cogstop cnt fit