An interpreted language that emulates an assembly (Kind of); Mostly just a fun language. User is required to use a stack, and can save values in memory. The challenge is to use a little memory as possible. Oh, do not forgot to pop the stack, it is not very big...
- Clone the repository
- Create
main.funcy
, and write a program - Make sure you have Python3.10 installed
- Type this in the terminal:
python3.10 funcy.py main.funcy
Put -d
before your .funcy
file if you want debug information.
- A stack of 4 elements is created which stores integers
- You get an infinitely growable chunk of memory, you can never give memory back to the system
- This is a safe language meaning in this case that instructions never pop from stack. Only possible with specific instruction
id
: Index of element in memoryexpr
: 32-bit integer, you have to put an 'i' before the number (i1234
)ident
: identifier for labels
Pop
: Pops the top of the stackStore <id|null>
: Saves the value on top of stack in a memory register- When
Store
has no arguments, it will use the top of the stack as the value and the second to top as memory location. Will free enough memory when there is not enough
- When
Push <id|expr>
: Pushes a value of a memory register or a value to the top of stackSwap
: Swaps the top 2 elements on the stackRot
: Rotates the top 3 elements on the stack:0, 1, 2
->1, 2, 0
Clear
: Empties the stack
Print
: Prints the value on the top of the stack in the terminalWrite
: Prints the value of the top of the stack as ASCII character (Decimal)
Equal
: Reads the top two elements of the stack, if they are not equal, you skip next instructionGreater
: Reads the top two elements of the stack, if left is not greater than right, you skip next instruction
Jump <ident>
Jumps to index of the instruction specified<ident>:
: A name of a label to jump to
Add
: Reads the top 2 elements on the stack, adds them together and pushes answer to stackMin
: Reads the top 2 elements on the stack, subtracts them and pushes answer to stackMultiply
: Reads the top 2 elements on the stack, multiplies them and pushes answer to stackDivide
: Reads the top 2 elements on the stack, divides them and pushes answer to stackModulo
: Reads the top 2 elements on the stack, pushes the remainder to the stack
;
: Means a comments until end of line