Casio_asm/doc/proc.md

2.2 KiB

The processor

This processor is a stack-based, big-endian custom processor. Its purpose is to execute bytecode independently of the actual platform. Its stack-based design is kinda inspied by the Java VM, but don't quote me on that.

The stack

This processor is equipped with a 256-slot stack, capable of holding both floating-point decimal numbers and integral numbers with 32-bit precision.
The stack is the destination to all result values from instructions and the source of input values if not explicitly supplied from registers.

There are 5 different operations possible on the stack:

  1. Push: Adds an element to the top of the stack
  2. Pop: Removes and retrieves the element currently on top of the stack
  3. Dup: Duplicates the element currently on top of the stack, effectively push-ing it twice
  4. Swap: Swaps the two highest elements currently on the stack
  5. Top: Returns the number of elements currently in the stack

The registers

This processor is equipped with 256 registers, #00 through #ff and #00 holds the program counter, or PC.
Just like the stack, each register can hold a 32-bit number which can be either a floating-point decimal number or an integral number.
Their purpose is to store information to be used in instructions instead of having to deal with stack push and pop.

The MMU

This processor is equipped with a Memory Management Unit, or MMU.
This MMU is used each time the processor tries to access memory, be it instruction data, sprites, files, VRAM, etc.
Contrary to standard memory managers, this MMU uses segmented memory instead of paginated memory to save as much RAM as possible on the host system.

The MMU defines three access permissions on each segment, and attempting to use them while they are absent will result in an interrupt being thrown.

  1. Readable
  2. Writable
  3. Executable

Segments in this MMU may refer to actual RAM, the stack, VRAM or even files.
The MMU handles segments in two different ways: if the data is in actual host RAM, then the segment is present and if it isn't, then the segment is absent and accessed through getters and setters.