Aryadev Chavali
90fb9816b4
Added new macro for bitwise comparison construction
...
This pushes a datum of the same type as the operands, which is why it
cannot use the comparator macro as that always pushes bytes.
2023-10-31 22:30:58 +00:00
Aryadev Chavali
5045452d7a
Added flag which forces the printing of hexes
...
Anything other than char (which can just use print.byte to print the
hex) and byte (which prints hexes anyway), all other types may be
forced to print a hex rather than a number if PRINT_HEX is 1.
2023-10-31 22:30:53 +00:00
Aryadev Chavali
d9aaaf2a53
Use macros to stop duplication of code
...
I've made a single macro which defines a function through some common
metric, removing code duplication. Not particularly readable per se,
but using a macro expansion in your IDE allows one to inspect the code.
2023-10-31 21:42:29 +00:00
Aryadev Chavali
5127202722
Introduced 3 new union members to data_t
...
These new members are just signed versions of the previous members.
This makes type punning and usage for signed versions easier than
before (no need for memcpy).
2023-10-31 21:41:53 +00:00
Aryadev Chavali
5202dfbb26
Remove duplicated code
2023-10-31 21:28:19 +00:00
Aryadev Chavali
f7f566b106
Implemented all the comparators
...
So much reused code, I definitely need to find a way to make this cleaner.
2023-10-31 21:24:54 +00:00
Aryadev Chavali
7817b5acc9
Use standardised signed version of word type from base.h
2023-10-31 21:24:50 +00:00
Aryadev Chavali
5d800d4366
Moved inst module to lib
...
As it has no dependencies on vm specifically, and it's more necessary
for any vendors who wish to target the virtual machine, it makes more
sense for inst to be a lib module rather than a vm module.
2023-10-31 21:14:14 +00:00
Aryadev Chavali
14a3820e74
Implemented new types of EQ, forced all comparators to push bytes
...
Just need to call their unsigned versions.
All comparators should push bytes as it makes return types uniform.
2023-10-31 21:05:25 +00:00
Aryadev Chavali
036d3dcfba
vm_execute_all: Print every cycle on VERBOSE >= 2, just print final state otherwise
...
Changed VERBOSE checks to ensure a degree of information.
2023-10-31 21:00:13 +00:00
Aryadev Chavali
4d8b855d87
Created routines for new comparator opcodes (not implemented)
...
Will cause error if used currently, which is fine.
2023-10-31 20:59:01 +00:00
Aryadev Chavali
0975d92493
Introduced new instructions for comparison
...
Comparing signed and unsigned versions of numbers. Same for EQ as
well.
Notice the irregular pattern of BYTE, CHAR, INT, HWORD,LONG,WORD as
OPCODE_IS_TYPE requires the subcodes to be surrounded by BYTE and
WORD.
2023-10-31 20:50:28 +00:00
Aryadev Chavali
157c79d53c
Added a "usage" message and colours for assembler
...
Prints useful and pretty messages when verbose being at least 1.
2023-10-29 16:59:31 +00:00
Aryadev Chavali
597a45aa73
Fixed bug where JUMP_REGISTER couldn't be in bytecode read
2023-10-29 16:58:18 +00:00
Aryadev Chavali
c4cb45f3ad
Fixed bug where reading operand bytecode may stop prematurely
...
This is due to checking for equality instead of just greater than in
darr->used against darr->available.
2023-10-29 16:56:33 +00:00
Aryadev Chavali
e9c54e045a
Fixed bug where printing hword of an instruction prints number not hex
...
This is an easy fix.
2023-10-26 11:16:02 +01:00
Aryadev Chavali
74a85268c4
Moved base functions from inst.c to dedicated file
...
Doesn't make sense for them to be in the VM module when they have a
more general purpose now.
2023-10-26 10:19:10 +01:00
Aryadev Chavali
c8c5381cf2
vm/main takes a filename as input to execute bytecode
...
Also prints a usage for incorrect usage.
2023-10-26 10:18:53 +01:00
Aryadev Chavali
42ac28d44a
Make root directory an include path, set #include's properly
...
Easier to write includes now just using < with the module name, in
comparison to using relative paths.
2023-10-23 04:46:09 +01:00
Aryadev Chavali
ac57e32a02
Added lib folder for general stuff, introduced as target to Makefile
2023-10-23 04:25:48 +01:00
Aryadev Chavali
aa4a3b8614
Implemented simple example of a for loop in main
2023-10-23 03:59:34 +01:00
Aryadev Chavali
b44a61be41
src->vm, Makefile is now a bit more abstracted and pretty colours
...
Changed folder names for sake of clarity (will be introducing a new
build target soon), and Makefile can now easily support more targets.
2023-10-23 03:58:34 +01:00