第 22 关,斐波那契参上。指令介绍请看:https://www.annhe.net/article-3828.html。
优化目标
19行156步
代码
20行136步
init:
INBOX
COPYTO 8
COPYFROM 9
COPYTO 0
BUMPUP 0
COPYTO 1
OUTBOX
out:
COPYFROM 1
OUTBOX
main:
COPYFROM 1
ADD 0
COPYTO 2
COPYFROM 1
COPYTO 0
COPYFROM 2
COPYTO 1
SUB 8
JUMPN out
JUMPZ out
JUMP init
19行156步
init:
INBOX
COPYTO 8
COPYFROM 9
COPYTO 0
COPYTO 1
BUMPUP 1
out:
COPYFROM 1
OUTBOX
main:
COPYFROM 1
ADD 0
COPYTO 2
COPYFROM 1
COPYTO 0
COPYFROM 2
COPYTO 1
SUB 8
JUMPN out
JUMPZ out
JUMP init
第一次pass 21行179步
init:
COPYFROM 9
COPYTO 0
COPYTO 1
BUMPUP 1
INBOX
COPYTO 8
COPYFROM 1
OUTBOX
main:
COPYFROM 1
ADD 0
COPYTO 2
COPYFROM 1
COPYTO 0
COPYFROM 2
COPYTO 1
COPYFROM 8
SUB 1
JUMPN init
COPYFROM 1
OUTBOX
JUMP main
18行154步
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
INBOX
COPYTO 5
SUB 5
COPYTO 0
COPYTO 1
BUMPUP 1
b:
OUTBOX
COPYFROM 1
ADD 0
COPYTO 2
COPYFROM 5
SUB 2
JUMPN a
COPYFROM 1
COPYTO 0
COPYFROM 2
COPYTO 1
JUMP b
30行104步
-- HUMAN RESOURCE MACHINE PROGRAM --
a:
b:
INBOX
COPYTO 0
COPYFROM 9
COPYTO 4
BUMPUP 4
COPYTO 8
OUTBOX
COPYFROM 8
COPYTO 7
OUTBOX
c:
COPYFROM 8
ADD 7
COPYTO 8
SUB 0
JUMPN e
JUMPZ f
JUMP a
d:
COPYFROM 8
ADD 7
COPYTO 7
SUB 0
JUMPN h
JUMPZ g
JUMP b
e:
f:
COPYFROM 8
OUTBOX
JUMP d
g:
h:
COPYFROM 7
OUTBOX
JUMP c
???厉害