Generalized Assembler

From Esolang
Jump to navigation Jump to search

Generalized Assembler by User:Zzo38 is a program which is used to create generalized assembly files. It also lets you write brainfuck programs inside the parenthesis. It can also be used to write esoteric programs as well. If you use this program on UNIX you have to make all of the filenames in uppercase otherwise it will not work. You can also use this program to run output-only brainfuck programs without modification (such as Hello World or 99 bottles of beer) if you put it all in one line.

Here is a examples of some macros that you can use with it:

\\ This macro does nothing, it is a blank macro
'nothing\macro
\endmacro

\\ This macro takes name from stack and uses as a hexadecimal number (1 byte)
'bytefromstack\macro
 \name1
 =*1
\endmacro

\\ This command stores "00" in parameter 9, and it isn't a macro
'00\name9

\\ This macro creates variables and numbers them sequentially
'var\macro
 \name1 \\ Get name of variable and store to parameter 1
 'nothing'*1\copy \\ Make a blank macro
 '*9'*1\pushname \\ Push value of parameter 9 to new macro
 'bytefromstack'*1\pushcmd \\ Push /bytefromstack command to new macro
 =*9(,+.)\byte9 \\ Add 1 to value of parameter 9
\endmacro

(Yes, you do have to write three macros to make the variables to be numbered! And you also have to write the numbers to the output and then take them away again!)

Here is another one, but I added error-checking:

'nothing\macro
\endmacro

'bytefromstack\macro
 \name1
 =*1
\endmacro

'00\name9

'varlimit1\macro
 \\ Variable OK, did not exceed limit
\endmacro

'varlimit0\macro
 'var.limit\echo\error
\endmacro

'var\macro \\ *** Create variable ('name /var)
 \name1
 'nothing'*1\copy
 '*9'*1\pushname
 'bytefromstack'*1\pushcmd
 =*9(,+.)\byte9
 =*9(,[<+>[-]]<.)\byte2/varlimit*2 \\ Error checking
\endmacro

This code is part of a file called PokemonScript that I am using to make a game called Pokemon CMQ.

Download: http://zzo38computer.org/gasm.zip