2 ms·
A toy 24-bit virtual machine and assembler. It has 16MB of addressable memory split into 256 64KB banks. 8 specialized and 8 general purpose 16 bit registers.
by grawprog 8y ago
A toy 24-bit virtual machine and assembler. It has 16MB of addressable memory split into 256 64KB banks. 8 specialized and 8 general purpose 16 bit registers. An address stack and a register state stack and memory mapped I/O.
Most of the opcodes have been written, apart from interrupts. It has built in function calls, near and far jumps, a bunch of different branching operations and basic looping based on flag States. Comparisons, unsigned and signed addition, multiplication, subtraction and division. Most opcodes support direct, indirect and relative addressing.
I tried to keep the assembly language fairly simple and straightforward. So far I have a two pass assembler that supports labels, named variables, subroutines, 8 and 16 bit numbers in decimal or hexadecimal format, 24 bit addresses in hexidecimal, character literals and zero terminated strings.
At this point the next steps are to finish doing interrupts and work on input and ouput. Right now, it will read an assembled binary and spit out a new binary with any modified memory addresses and a register dump so there's still a bit of work yet to making something interactive.
I'm thinking of using bearlibterminal(though I wouldn't mind keeping it dependency free...i'm just not sure if I can) and making it pseudo text/graphical terminal based I was thinking of maybe having different modes that could be switched so data stored in vram memory would be treated and displayed differently depending. I'd also like to keep the display and input fairly separate so it would be possible to write a different display frontend if people wanted. My hope is to eventually have keyboard, mouse and maybe other inputs, graphics and basic audio all as separate modules.
I'd like to eventually release it all open source with full documentation. I dunno I was inspired after trying to learn assembly and finding it was either fairly complex and more for compilers in the case of modern processors or you had to deal with weird hardware limitations and strangeness with old processors. So I tried my hand at making something similar to an older processor without having to deal with the frustrations of old hardware. My goal was to make it as fun to program in as possible while still giving the feeling of working directly with memory and registers.
Personally, i've learned tons from working on this and I figure if I was looking something like this, there's probably others that could benefit.