Aryadev Chavali
2bc20f07d3
Added vm_execute support for mov routines
...
Similar to push routines support. Easy to extend by adding items to
the MOV_ROUTINES array.
2023-10-15 21:05:56 +01:00
Aryadev Chavali
3f8544485a
Move push routines outside of vm_execute
2023-10-15 21:05:09 +01:00
Aryadev Chavali
56c545e7c9
Added opcodes for MOV and ability for instructions to hold registers
...
Pretty simple implementation
2023-10-15 21:03:27 +01:00
Aryadev Chavali
33aa62634a
Added registers to virtual machine
...
Registers for bytes, words and floats with routines to set them.
2023-10-15 21:01:03 +01:00
Aryadev Chavali
7a820290f9
Make push opcodes a specific bit set and add a NOOP opcode
...
By default, a zero initialised set of instructions are NOOPs, which is
great.
Last two bits of a push opcode is always 01. Rest of the bits are
used to distinguish between differing types of push. This makes it
easier to inspect on the byte level what type of opcode we have.
2023-10-15 20:59:26 +01:00
Aryadev Chavali
40dfa5c255
Split off instruction structure to its own file
2023-10-15 17:38:35 +01:00
Aryadev Chavali
ea14b3beb6
Added an instruction setup
...
op_t provides opcodes, inst_t provides a wrapper with operands. vm_t
carries around a pointer to a set of instructions, and vm_execute
attempts to execute that one. I do some weird stuff here, and it's
definitely not complete.
2023-10-15 05:52:58 +01:00
Aryadev Chavali
3786b7d785
stack.size -> stack.max
2023-10-15 05:44:06 +01:00
Aryadev Chavali
4ddc3cce71
Main now loads a stack allocated byte array for VM stack
2023-10-15 05:41:20 +01:00
Aryadev Chavali
bee6d445bb
Added a routine to load a pointer as stack memory
2023-10-15 05:40:53 +01:00
Aryadev Chavali
2de37b20e2
Changed stack data to be a pointer
...
I wouldn't really want this to be malloc'd per se, you could make a
byte array on the stack then pass it into the VM?
2023-10-15 05:39:19 +01:00
Aryadev Chavali
a8747faa08
Split off general types and structures into separate header
2023-10-15 05:36:01 +01:00
Aryadev Chavali
da1c4aad35
Changed stack.pointer->stack.ptr
2023-10-15 05:33:42 +01:00
Aryadev Chavali
268fdf0ca0
Added floats (64 bit floating point) push and pop routines
...
Not machine independent, uses the underlying memcpy routine.
2023-10-15 05:23:38 +01:00
Aryadev Chavali
724f5e0258
Force big endian when pushing words
...
This ensures that if one wanted to pop a word byte by byte, they'd go
from least to most significance. Machine independent so that's nice.
2023-10-15 05:18:43 +01:00
Aryadev Chavali
54b836ba64
Add macro for size of a word
...
Smaller number of changes necessary to change types.
2023-10-15 05:03:09 +01:00
Aryadev Chavali
cfc9edebba
Added macro constructors for union types
2023-10-15 04:57:38 +01:00
Aryadev Chavali
1180833161
Implemented functions to pop a byte and a word
2023-10-15 04:57:30 +01:00
Aryadev Chavali
d52d7ad413
Implemented a union type to make vm_push_* routines uniform
...
Function dispatch
2023-10-15 04:36:47 +01:00
Aryadev Chavali
49a85a20d8
Added functions to push a byte and a word
...
Maybe I should make a union for the type, so I can dispatch via
function pointers?
2023-10-15 04:35:07 +01:00
Aryadev Chavali
1101716f0f
Defined a simple virtual machine data structure
...
Currently just contains a "stack".
2023-10-15 01:35:05 +01:00
Aryadev Chavali
ca2e9c7083
Added some type aliases
...
Nicer to refer to a byte as "byte" rather than "uint8_t"
2023-10-15 01:34:42 +01:00
Aryadev Chavali
7cf9160e3f
Added a README
2023-10-15 01:30:00 +01:00
Aryadev Chavali
b6672121a1
Remove unit tests from github workflow
...
We don't *have* unit tests lol.
2023-10-15 01:27:46 +01:00
Aryadev Chavali
16e2275576
First commit!
...
This is a from the ground rework of an old project of the same name.
I'm hoping to be more concerned with runtime efficiency, bytecode size
and all those things that should actually matter for something that
may host time/space critical code.
2023-10-15 01:25:24 +01:00