Skip to content

Instantly share code, notes, and snippets.

@Nabb
Created April 16, 2012 07:40
Show Gist options
  • Save Nabb/2396963 to your computer and use it in GitHub Desktop.
Save Nabb/2396963 to your computer and use it in GitHub Desktop.
Whitespace Assembler
"":d;
[]:VAR;
{|2>~2base(;{" \t"=}%n+}:LB;
{|~F}:N;{..abs<\2base+{" \t"=}%+"\n"+}:F;
{n%{{1<"#"=!}1$!!*},{"|"%~}%{
:|' '/0=.58,48>-\,1>{'-'-}*"PUSH"or:I;[
["PUSH"{" "N}]
[".""DUP""d"" \n "]
["$""COPY"{" \t "|1>~)F}]
["\\""SWAP""r"" \n\t"]
[";""POP""DEL"" \n\n"]
["SLIDE"{" \t\n"N}]
["+""ADD""\t "]
["-""SUB""\t \t"]
["*""MUL""\t \n"]
["/""DIV""\t \t "]
["%""MOD""\t \t\t"]
["s""STORE""PUT""\t\t "]
["l""GET""RETRIEVE""\t\t\t"]
["L""LABEL"{"\n "LB}]
["CALL"{"\n \t"LB}]
["J"{"\n \n"LB}]
["JZ"{"\n\t "LB}]
["JLZ""JN"{"\n\t\t"LB}]
["RET""\n\t\n"]
["OC""OUTCHAR""\t\n "]
["ON""OUTNUM""\t\n \t"]
["GETC""CHARIN""\t\n\t "]
["NUMIN""\t\n\t\t"]
["IC"{"0|GETC|0|l"GO}]
["IN"{"0|NUMIN|0|l"GO}]
["#"""]
["STRING"{|~{" "\F"\t\n "}/}]
["DEBUG"{d"|"^:d;}]
["VAR"{|4>.VAR?:tmp)!{VAR,:tmp;[.]);VAR\+:VAR}*;tmp)" "\F}]
["LVAR"{|1>"|l"+GO}]
["SVAR"{|1>"|r|s"+GO}]
["END""\n\n\n"]
]
{[I]&}?-1=.`0=100>{~}*d
}:P%}:GO~
"":n; #skip trailing n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment