solutions to the levels matching the file name
This commit is contained in:
10
src/masking_time.asm
Normal file
10
src/masking_time.asm
Normal file
@@ -0,0 +1,10 @@
|
||||
#include "../definitions.asm"
|
||||
|
||||
prog:
|
||||
imm6 0b000011
|
||||
load r0, r2
|
||||
in r1
|
||||
and
|
||||
out r3
|
||||
.result:
|
||||
.halt:
|
||||
37
src/special_invasion.asm
Normal file
37
src/special_invasion.asm
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "definitions.asm"
|
||||
; spacial invasion level
|
||||
; man this level is dumb...
|
||||
; 0 - turn left
|
||||
; 1 - forward
|
||||
; 2 - turn right
|
||||
; 3 - wait
|
||||
; 4 - action
|
||||
; 5 - shoot
|
||||
prog:
|
||||
|
||||
imm6 1 ; setup forward
|
||||
load r0, r4
|
||||
imm6 5 ; setup shoot
|
||||
load r0, r5
|
||||
imm6 3 ; setup wait
|
||||
load r0, r2
|
||||
out r5 ; shoot block in front of us and move into postition
|
||||
out r4 ; forward 1
|
||||
out r4 ; forward 2
|
||||
out r4 ; forward 3
|
||||
out r4 ; forward 4
|
||||
out r4 ; forward 5, setup complete time to start blast'n
|
||||
.detect_loop:
|
||||
in r3
|
||||
imm6 prog.detect_none
|
||||
beqz ; if input not eq to 0 (no item) then shoot, else wait
|
||||
.detect_some:
|
||||
out r5 ; shoot and then branch to prog.result
|
||||
imm6 prog.result
|
||||
ba
|
||||
.detect_none:
|
||||
out r2 ; else wait 1
|
||||
.result:
|
||||
imm6 prog.detect_loop
|
||||
ba
|
||||
.halt:
|
||||
38
src/storage_cracker.asm
Normal file
38
src/storage_cracker.asm
Normal file
@@ -0,0 +1,38 @@
|
||||
#include "definitions.asm"
|
||||
;
|
||||
; Solution to Storage Cracker level on TC
|
||||
; Output is the guess to 'crack the code'
|
||||
; Input is 1 if the guess was too high and 0 if low
|
||||
;
|
||||
; Uses r0, r1, r2, r5
|
||||
; Unused r4
|
||||
prog:
|
||||
imm6 1
|
||||
load r0, r1
|
||||
load r0, r2
|
||||
ror ; make a 0b1000_0000 from 0b00000001 ROR 1
|
||||
; 128 in r3
|
||||
load r3, r5 ; save as starting point
|
||||
.loop_1:
|
||||
out r3
|
||||
in r3
|
||||
|
||||
imm6 prog.low ; if input is 1 the code is a higher number, if 0 its lower
|
||||
beqz ; branch if r3 == 0
|
||||
|
||||
load r5, r1 ; saved value of previous loop/or starting point
|
||||
imm6 1 ; step size
|
||||
load r0, r2
|
||||
.high:
|
||||
sub ; current - 1 = next guess
|
||||
load r3, r5
|
||||
imm6 prog.result ; jump over low
|
||||
ba
|
||||
.low:
|
||||
add ; current + 1 = next guess
|
||||
load r3, r5 ; save for next round
|
||||
.result:
|
||||
imm6 prog.loop_1 ; branch back to the start
|
||||
ba
|
||||
.halt:
|
||||
halt
|
||||
60
src/the_maze.asm
Normal file
60
src/the_maze.asm
Normal file
@@ -0,0 +1,60 @@
|
||||
#include "../definitions.asm"
|
||||
; 0 - turn left
|
||||
; 1 - forward
|
||||
; 2 - turn right
|
||||
; 3 - wait
|
||||
; 4 - action
|
||||
; 5 - shoot
|
||||
prog:
|
||||
imm6 2 ; turn right
|
||||
out r0
|
||||
|
||||
.check_wall:
|
||||
; check if the input - 1 == 0, which means it is a wall on our right
|
||||
imm6 1 ; wall id
|
||||
load r0, r2
|
||||
in r1
|
||||
xor
|
||||
imm6 prog.left2 ; if there is a wall on our right turn left twice
|
||||
beqz
|
||||
.check_empty:
|
||||
imm6 0 ; id for empty cell
|
||||
load r0, r2
|
||||
in r1
|
||||
xor
|
||||
imm6 prog.fwd ; move into empty spaces
|
||||
beqz
|
||||
.check_coin:
|
||||
imm6 8 ; id for coin
|
||||
load r0, r2
|
||||
in r1
|
||||
xor
|
||||
imm6 prog.fwd ; move on top of coins
|
||||
beqz
|
||||
.check_door:
|
||||
imm6 3 ; id for door
|
||||
load r0, r2
|
||||
in r1
|
||||
xor
|
||||
imm6 prog.action ; if item is a door use action
|
||||
beqz
|
||||
|
||||
imm6 prog
|
||||
ba ; if the space isn't empty, a wall, a coin, or a door, loop again
|
||||
.fwd:
|
||||
imm6 1 ; fwd
|
||||
out r0
|
||||
imm6 prog
|
||||
ba
|
||||
.left2:
|
||||
imm6 0 ; rotate left twice
|
||||
out r0
|
||||
out r0
|
||||
imm6 prog
|
||||
ba
|
||||
.action:
|
||||
imm6 4 ; use cell in front of robot
|
||||
out r0
|
||||
|
||||
imm6 prog
|
||||
ba
|
||||
Reference in New Issue
Block a user