Compare commits
No commits in common. "e70580785fe54b518f7a10e23f0e15b4263a68a5" and "d1a8792b18210794761801edd8559f8fc817e6c9" have entirely different histories.
e70580785f
...
d1a8792b18
3 changed files with 8 additions and 8 deletions
|
@ -1,13 +1,13 @@
|
||||||
# Stupid Worm Languag
|
# Stupid Worm Languag
|
||||||
- program space is an arbitrary sized grid of bytes
|
- program space is an arbitrary sized grid
|
||||||
- the worm starts as just a head `@`
|
- the worm starts where you place the worm head @
|
||||||
- as it passes over commands, they get moved to the back of the worm
|
- as it passes over commands, they get moved to the back of the worm
|
||||||
- values get pushed to stack (eaten) when passed over, worm body length increases
|
- values get pushed to stack (eaten) when passed over, worm body length increases
|
||||||
- the program gets rearranged every time the worm executes it
|
- the program gets rearranged every time the worm executes it
|
||||||
|
|
||||||
## commands
|
## commands
|
||||||
```
|
```
|
||||||
+- pop 2 values, push sum/difference (uses the order they are popped, so `0-` negates the top of the stack)
|
+- pop 2 values *, push sum/difference (uses the order they are popped, so `0 -` negates the top of the stack)
|
||||||
><^v change direction
|
><^v change direction
|
||||||
0..9 push number to stack
|
0..9 push number to stack
|
||||||
/\ pop stack, reflect to the side if not zero
|
/\ pop stack, reflect to the side if not zero
|
||||||
|
@ -15,6 +15,5 @@
|
||||||
= duplicate top of stack
|
= duplicate top of stack
|
||||||
! pop and write output as ascii char
|
! pop and write output as ascii char
|
||||||
" pop and write output as number
|
" pop and write output as number
|
||||||
_ push a space character
|
|
||||||
all other characters are pushed as-is
|
|
||||||
```
|
```
|
||||||
|
* pop when stack is empty yields zero
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
!!!!!!!!!!!!!Hello,_world+1_@<
|
|
|
@ -225,8 +225,10 @@ impl SandWormInterpreter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
b' ' | 0 => dont_push_instruction = true,
|
b' ' | 0 => dont_push_instruction = true,
|
||||||
b'_' => self.worm_in.push(b' '),
|
other => {
|
||||||
other => self.worm_in.push(other),
|
self.worm_in.push(other);
|
||||||
|
dont_push_instruction = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if !dont_push_instruction {
|
if !dont_push_instruction {
|
||||||
self.worm_out.insert(0, instruction);
|
self.worm_out.insert(0, instruction);
|
||||||
|
|
Loading…
Reference in a new issue