asmscript

Procedures

There is only one construct that can exist at the top-level of an asms file - procedure declaration. A procedure has a unique name and contains a block of statements.

proc NAME {
    STATEMENTS
}

You don't specify arguments or return types for procedures. It is up to you to decide how you will pass arguments and return values. In other words, you are responsible for defining and following your own calling convention.

A procedure name cannot be a reserved keyword and has to satisfy this regular expression:
[_a-zA-Z][_a-zA-Z0-9]*
Procedure named "main" is special and is considered the entry point. You must have a procedure named "main" in your program.

You can call a procedure using a call statement, which will emit a "call" instruction. A "ret" instruction is placed at the end (and also at every return statement), so you don't have to use a return statement if you don't need to.

Entry point

main isn't actually the true entry point. Right before calling main, every register you have access to is pushed on the stack, and then popped after main returns. This ensures that you can use registers in your code as you wish without worrying about breaking the calling convention of the JIT compiler.