Writing an Atom Program

The basic syntax of Atom assembler is:

If the opcode requires a register, the first register in the parameter list is the register being loaded. For example, for the set opcode:

set: R1, 0

The register R1 is being set to 0. All opcodes behave in a similar manner. Registers are numbered 1 though 64 and are of type Variant. The variant type can hold a numeric value or a string, and the values can change depending on what is being loaded.

For opcodes that take more than one register, the first register is always loaded with the result of the action of following registers.

The VM will execute code in a linear fashion until a branching statement is encounterd (goto, gosub, branch or subroutine), until the end opcode is encountered or until the last line of code has been executed. If a branch statement points off the execution stack, a runtime error is generated.


	     print: "Let's gosub!"
	     gosub: INSUB
	     print: "How was that?"
INSUB@	print: "We are gosubbing."

In this example, the VM will execute each line of code until it reaches the gosub opcode. Execution will then move to the line with the INSUB label. When the return opcode is encountered, the vm will begin executing code with the next line following the gosub. When the end opcode is encountered, the program ends.

So the program flow here is:

  1. print: "Let's gosub!"
  2. gosub: INSUB
  3. INSUB@ print: "We are gosubbing."
  4. return:
  5. print: "How was that?"
  6. end:

Notice that in this example, the end is required since we are jumping to code that should only be executed once.

The Atom VM is a Win32 console program. To run a program, open a console window and type atomvm filename.ata. The extension is required.

There is no limits on the program size, number of labels, number of items on the data or frame stack, or length of strings, other than computer memory.