Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Command: perl -00 -pe 's/\D*(\d+),?/$1 /g' <input | dc -fdc-p1.dc | sed -e's/,$//'
- # Load registers
- ? sc sb sa
- ? # blank line
- # Load code
- ? zsn
- [
- z1-:c
- z0<L
- ] dsLx
- # XOR of top two elements (lowest three bits)
- # Uses (A + B*(-1^A)) % 4 for 2-bits and +2% for the third
- [
- 4~ 3R 4~ # (B-low2) (B-rest) (A-low2) (A-rest)
- 3R
- d_1r^3R*+4d3R+r% # (B^A low2) (B-rest) (A-rest)
- _3R
- +2% # (B^A third) (B^A low2)
- 4*+
- ] s^
- [ s.laq ] sA # replace top with A
- [ s.lbq ] sB # replace top with B
- [ s.lcq ] sC # replace top with C
- # Resolve combo referencing:
- [
- d 4=A
- d 5=B
- d 6=C
- ] sR
- [r] sr
- [ lRx 2r^ lar/ sa ] 0:o # adv
- [ lRx 2r^ lar/ sb ] 6:o # bdv
- [ lRx 2r^ lar/ sc ] 7:o # cdv
- [ lRx 8% sb ] 2:o # bst
- [ lRx 8% n44an ] 5:o # out
- [ 2- la 0!=r s. ] 3:o # jnz
- [ lb l^x sb ] 1:o # bxl
- [ s. lblc l^x sb ] 4:o # bxc
- # stack frame: ip
- 0
- [
- dd 1+;c
- r;c ;ox # [block]x arg ip => ip
- 2+d ln>M
- ] dsMx
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement