Emulation of my own made up CPU architecture since I can't spend the time to learn one.
Sample input file:
PLACEW RWx0004 0x0000 ; Clean up register, make sure it's 0x00
PLACEW RWx0005 0x0005 ; Initialize the counting register
PLACEW RWx0006 0x003d ; Declare max variable
_PRINT_VALUES:
ADDW RWx0004 RWx0005 ; Add the fifth register (0x05) to the 4th register
PRINTHEXW RWx0004 ; Print the counting register in hexadecimal form
JMPW _COMPARE ; Go back to comparing
_HALT:
HLT ; Halt program on success
_COMPARE:
GTW RWx0004 RWx0006 _HALT _PRINT_VALUES ; If greater, quit, if smaller, increment
Corresponding bytecode output:
�� �� � �� = �� � �� � ��� � � �
Onscreen output at runtime:
Running Examples/counting.wor.out
Successfully initialized Registers, Memory, and Instruction Set
Program Data:
0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f
0x0000 0x16 0x04 0x00 0x00 0x00 0x16 0x05 0x00 0x05 0x00 0x16 0x06 0x00 0x3d 0x00 0x17
0x0010 0x04 0x00 0x05 0x00 0x1c 0x04 0x00 0x20 0x1b 0x00 0x13 0x1e 0x04 0x00 0x06 0x00
0x0020 0x1a 0x00 0x0f 0x00
Register 0x0004: 0x0005
Register 0x0004: 0x000a
Register 0x0004: 0x000f
Register 0x0004: 0x0014
Register 0x0004: 0x0019
Register 0x0004: 0x001e
Register 0x0004: 0x0023
Register 0x0004: 0x0028
Register 0x0004: 0x002d
Register 0x0004: 0x0032
Register 0x0004: 0x0037
Register 0x0004: 0x003c
Register 0x0004: 0x0041
Successfully exited from emulation.