EXAPUNKS

EXAPUNKS

View Stats:
My solution to Digital Library Project
XA:
GRAB 300

MARK LOOP
TEST EOF
TJMP END
COPY F X
COPY X M
COPY M T
COPY X M
COPY T M
JUMP LOOP

MARK END
COPY 0 M
COPY M X
HALT

XB:
LINK 800

MARK GETADDRESS
SWIZ M 3 X
COPY X M
TEST X = 0
TJMP END
MARK ADVANCE
SUBI X 1 X
LINK 800
TEST X = 0
FJMP ADVANCE
SWIZ M 21 X
ADDI X 200 X
GRAB X
MODE
REPL TRANSCRIBE
COPY M X
MARK SENDINGTEXT
TEST EOF
TJMP RETRIEVE
COPY F M
JUMP SENDINGTEXT

MARK TRANSCRIBE
MAKE
FILE M
MARK TRANSCRIBELOOP
COPY M F
JUMP TRANSCRIBELOOP

MARK RETRIEVE
MODE
KILL
DROP
GRAB X
COPY M X
MARK RETURN
LINK -1
TEST X > 0
FJMP RESET
SUBI X 1 X
JUMP RETURN

MARK RESET
DROP
LINK 800
JUMP GETADDRESS

MARK END
HALT

This gets the job done but scores poorly in all 3 fields... there was a smarter way to do it? xD
< >
Showing 1-6 of 6 comments
More REPL, and fetch all books at once.

I can share my solution if you like (298 cycles), but I think it's more fun to optimize on ones own.
Some little remarks, with little impact:

GRAB 300

MARK LOOP
TEST EOF
TJMP END
COPY F X
COPY X M
COPY M T
COPY X M
COPY T M
JUMP LOOP

MARK END
COPY 0 M
COPY M X
HALT

You know that the file contains data, so you do not need to check EOF at the beginning. That way, you can spare some cylces and some commands (MARK does count as one as well, BTW). And you don't need HALT if it's the last command, the EXA 's gonna stop anyway.

GRAB 300

MARK LOOP
COPY F X
COPY X M
COPY M T
COPY X M
COPY T M
TEST EOF
FJMP LOOP

COPY 0 M
VOID M
Another remark: Sometimes, you can count/calc on T instead of X and spare the TEST:

SWIZ M 3 X
COPY X M
TEST X = 0
TJMP END

=>

SWIZ M 3 T
COPY T M
; TEST X = 0
FJMP END

Even more important than sparing the test is that you've got your general purpose register X still free for something else!
Originally posted by Zyro:
Another remark: Sometimes, you can count/calc on T instead of X and spare the TEST:

SWIZ M 3 X
COPY X M
TEST X = 0
TJMP END

=>

SWIZ M 3 T
COPY T M
; TEST X = 0
FJMP END

Even more important than sparing the test is that you've got your general purpose register X still free for something else!

all great hints, I'll try to apply in my next solutions, thank you! :)
Originally posted by マルコ:
all great hints, I'll try to apply in my next solutions, thank you! :)

I also came late to the party, got about 100 hours (some AFK I guess) into it and I'm chewing on the last levels at the moment. Would be happy to give more code reviews/hints if you like.
Originally posted by Zyro:
Originally posted by マルコ:
all great hints, I'll try to apply in my next solutions, thank you! :)

I also came late to the party, got about 100 hours (some AFK I guess) into it and I'm chewing on the last levels at the moment. Would be happy to give more code reviews/hints if you like.

I might have more bad code down the line xD
Btw, I had actually misunderstood T, I thought it would reset every time you touch it (like with the COPY in the example above), but after seeying your example, its clear it gets overwritten only when you perform a TEST.
This will surely change my solutions going forward :P
< >
Showing 1-6 of 6 comments
Per page: 1530 50