第 39 关,重设坐标。指令集介绍请看:https://www.annhe.net/article-3828.html。
优化目标
14行76步
代码
35行44步
见 Github。
14行73步
见 Github。跟 15 行 79 步类似,15 行的问题是 COPYFROM 11
执行了两次,为了省去最后一步的 COPYFROM 14 COPYTO 1
,导致 INBOX 取的数先存后取,且还是在循环内取,因此多执行了几步。
JUMP next
out:
ADD 15
OUTBOX
COPYFROM 1
OUTBOX
next:
COPYFROM 14
COPYTO 1
INBOX
cal:
SUB 15
JUMPN out
COPYTO 0
BUMPUP 1
COPYFROM 0
JUMP cal
15行79步
JUMP next
out:
ADD 15
OUTBOX
COPYFROM 1
OUTBOX
next:
INBOX
COPYTO 11
COPYFROM 14
COPYTO 1
cal:
COPYFROM 11
SUB 15
JUMPN out
COPYTO 11
BUMPUP 1
JUMP cal
38行66步
COPYFROM 15
ADD 15
COPYTO 11
ADD 15
COPYTO 7
JUMP next
out:
OUTBOX
next:
COPYFROM 14
COPYTO 0
INBOX
SUB 15
JUMPN y0
ADD 15
SUB 11
JUMPN y1
ADD 11
SUB 7
JUMPN y2
OUTBOX
BUMPUP 0
BUMPUP 0
BUMPUP 0
JUMP out
y0:
ADD 15
OUTBOX
COPYFROM 0
JUMP out
y1:
ADD 11
SUB 15
OUTBOX
BUMPUP 0
JUMP out
y2:
ADD 7
SUB 11
OUTBOX
BUMPUP 0
BUMPUP 0
JUMP out
第一次pass 15行84步
next:
COPYFROM 14
COPYTO 1
INBOX
COPYTO 11
cal:
COPYFROM 11
SUB 15
JUMPN x
COPYTO 11
BUMPUP 1
JUMP cal
x:
ADD 15
OUTBOX
COPYFROM 1
OUTBOX
JUMP next
发表回复