@yBASIC, pronounced “SnailBASIC” is a language subset for the 3DS interpreter SmileBASIC.
One problem people often have with BASIC dialects is that there are not enough punctuation characters required. @yBASIC attempts to remedy this. In fact, the only alphanumeric characters used are those for “GOTO”
Note that live snails (@y) are not permitted in SnailBASIC: only deceased snails (@_) are valid.
@yBASIC can take no input, because snails are obstinate and don’t care what you want them to do.
snailbasic.ps1 is a compiler from an assembly-like symbolic system to @yBASIC. Please submit issues as you encounter them.
source.txt:
MOV A,1 @0 PUSH MOV A,A--A PRINT A GOTO @0
.\snailbasic source.txt -stdout
_$=""_=(!.)@_:GOTO "@__"+"_"*!!_@__:_$=_$+"."GOTO@____@___:_$=_$+"_"@____:_%=_%--!._=_--_?_:GOTO@_
- One instruction per line.
- Labels must begin at the first column of their line.
- Labels are in the form
@[0-9]+
. - Labels must take sequential numbers to avoid unexpected behavior (the compiler generates labels starting at the end of <# user labels>.
- PUSH, POP, UNSHIFT, and SHIFT all work directly with the A variable only.
- Comments are begun by either ’ or ; and result in the rest of the line being ignored.
- Valid variables are [A-Z]
GOTO @#
Jump to a label.
MOV [A-Z],Expression
Assign result of expression to a variable. Expressions undergo the following transformations:
[A-Z]
-> respective_
variable[0-9]+
->(!.+)
construction0
->.
IF [A-Z]
If the variable is truthy, evaluate the next instruction (do nothing). Otherwise, skip one instruction.
PRINT [A-Z]
Print the value of the specified variable to console.
SET [A-Z]
Write the logical value of A
to the binary tape at the index specified
GET [A-Z]
Read from the binary tape at the index specified into A
UNSHIFT
Unshift the logical value of A
to the beginning of the binary tape
SHIFT
Shift the beginning of the binary tape into A
PUSH
Push the logical value of A
to the end of the binary tape
POP
Pop the end of the binary tape into A