Skip to content

compiler

Ccode-lang edited this page Feb 16, 2022 · 4 revisions

The compiler is an easier way to write code for the vm. It also allows you to write hex numbers/ascii in decimal.

usage

python3 chexcomp.py <file to compile>

commands

pr <address in memory to print from>

This command prints one character from the given address.
Example:

; print ascii stored at address 0x00
pr 0

jmp <address to jump to>

Jump to address given
Example:

; jump to offset 2 (program start)
jmp 2

str <address to store at> <value to store>

Stores a byte at the given address
Example:

; store an ascii value of h at address 0
str 0 104

jmpmem <place stored in memory you want to jump to>

Jumps to program offset stored in memory.
Example:

; store location of program start in memory
str 0 2
; jmp to it
jmpmem 0

jmpeq <memory location one> <memory location two> <place to jump too>

Compares two values stored in memory and jumps to offset given if they are equal.
Example:

; store one and two in memory
str 0 1
str 1 1

; see if they are equal and jump to program start if they are equal (so this program is basically just an over complicated forever loop)
jmpeq 0 1 2