cpu that i made in 4 days using c++ with zero knowledge of cpu`s before.
It can multiply, add, substract, divide two numbers.
It can print from reg0. Beep and it can write or read from/to file.
It has its own basic binary code eg opcodes.
Also it has checks for overflow and underflow(very basic).
in main.cpp you can run it and edit memory then load it to cpu.
Feel free to use it or upgrade it :)
Here is the list of instructions:
MOV_R0 ;moves val to r0
MOV_R1 ;moves val to r1
ADD ; r0 = r0 + r1
MUL ; r0 = r0 * r1
SUB ; r0 = r0 - r1
DIV ; r0 = r0 / r1
JE ; jumps to specified memory location if r0 equals r1
JNE ; jumps to specified memory location if r0 != r1
JM ; jumps to specified memory location
PRINT ; prints r0 from specified memory location
BEEP ; beeps (\a)
STORE ; stores r0 to specified memory location
CLEAR_R0 ; sets r0 to 0
CLEAR_R1 ; sets r1 to 0
HALT ; end of the program
NOP ; for readability
PFC ; sets print flag to char eg std::cout << static_cast(97); = a
PFI ; sets print flag to int also its default on start
1.you can compile it and run it as an executable file.
2. you can run an exe file virtualcpu4001.exe or virtualcpu4001v3.exe they are indentical.
Also it starts from second memory address
because CPU reserves 1 byte for jump address and the other one for extra halt instruction!
to open a file you have to do this in menu(main.cpp)
select 5
press enter
select r
press enter
type filename
press enter
boom magic.
load instructions in memory
select 4
press enter
select r
press enter
type filename to make
press enter
boom magic