/SRegMachine

Simple register machine for learning assembler (Windows .NET)

Primary LanguageC#MIT LicenseMIT

SRegMachine

Simple register machine for learning assembler (Windows .NET 4.8)

SRegMachine_Image

Instruction List

Loading and moving Values

LOADI <reg0> $value # Load the value '$value' into register 'reg0'
MOV <reg0> <reg1> # Copyies the value from 'reg1' into 'reg0'

Math with registers

Every math instructions will set flags (zero, neg, ov)

ADD <reg0> <reg1> # 'reg0' = 'reg0' + 'reg1'
SUB <reg0> <reg1> # 'reg0' = 'reg0' - 'reg1'
MUL <reg0> <reg1> # 'reg0' = 'reg0' * 'reg1'
DIV <reg0> <reg1> # 'reg0' = 'reg0' / 'reg1'
MOD <reg0> <reg1> # 'reg0' = 'reg0' % 'reg1'

Math with integers

Every math instructions will set flags (zero, neg, ov)

ADD <reg0> $value # 'reg0' = 'reg0' + 'value'
SUB <reg0> $value # 'reg0' = 'reg0' - 'value'
MUL <reg0> $value # 'reg0' = 'reg0' * 'value'
DIV <reg0> $value # 'reg0' = 'reg0' / 'value'
MOD <reg0> $value # 'reg0' = 'reg0' % 'value'

Jumping

Labels are defined by typing a ':' (Collum)

JMP $label_name # Will jumpt to 'label_name'
JMPZ $label_name # Will jumpt to 'label_name' when zero flag is set
JMPNZ $label_name # Will jumpt to 'label_name' when zero flag is NOT set
JMPN $label_name # Will jumpt to 'label_name' when negative flag is set
JMPNN $label_name # Will jumpt to 'label_name' when negative flag is NOT set
JMPO $label_name # Will jumpt to 'label_name' when overflow flag is set
JMPNO $label_name # Will jumpt to 'label_name' when overflow flag is NOT set

Flow Control

HOLD # Will hold the execution
RST # Will reset to the first instuction (continues execution)
EOF # End of file (RST + HOLD)