Skip to content

y-ack/SnailBASIC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 

Repository files navigation

@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.

Examples

source.txt:

MOV A,1
@0
PUSH
MOV A,A--A
PRINT A
GOTO @0

.\snailbasic source.txt -stdout

_$=""_=(!.)@_:GOTO "@__"+"_"*!!_@__:_$=_$+"."GOTO@____@___:_$=_$+"_"@____:_%=_%--!._=_--_?_:GOTO@_

Source Rules

  • 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]

Symbolic Language Instruction List

GOTO

GOTO @#

Jump to a label.

MOV

MOV [A-Z],Expression

Assign result of expression to a variable. Expressions undergo the following transformations:

  • [A-Z] -> respective _ variable
  • [0-9]+ -> (!.+) construction
  • 0 -> .

IF

IF [A-Z]

If the variable is truthy, evaluate the next instruction (do nothing). Otherwise, skip one instruction.

PRINT :likely to change:

PRINT [A-Z]

Print the value of the specified variable to console.

SET

SET [A-Z]

Write the logical value of A to the binary tape at the index specified

GET

GET [A-Z]

Read from the binary tape at the index specified into A

UNSHIFT

UNSHIFT

Unshift the logical value of A to the beginning of the binary tape

SHIFT

SHIFT

Shift the beginning of the binary tape into A

PUSH

PUSH

Push the logical value of A to the end of the binary tape

POP

POP

Pop the end of the binary tape into A

About

Joke SmileBASIC language subset

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published