having nothing better to do tonight
i knocked out a virtual cpu.
register based
(16 registers,
reg0 is always zero,
reg15 is instusction pointer
reg14 is flags
reg13 is stack pointer)
is a risc design. all register to register except 1 command, which takes a 32bit number in.
there is only 13 commands, some things need to be 'emulated' with other commands (eg: push/pop)
i've already written the virtual machine in C so now all i need to do is write a c-like compiler...
i'm thinking of using it in my stuff as embedded scripting.
i did get a bit lazy, i could have implemeted sub/div/mul all as 'add' commands but i couldnt be arsed I'm strictly following RISC here...
and there is only 2 flags, overflow and equal...
since its mostly register 2 register opcodes, the guts of the VM that handles all the opcodes is only 140 lines of code.. sweet.. once I add some memory handle stuff for the execing binary, i'll be set... hmmm...
now in the parser for the compiler is it BODMAS or BOMDAS... hmmm I havnt thought of that since high school...
BODMAS
(1+1) * 4 / 2 --> 2 * 4 / 2 --> 2 * 2 --> 4
BOMDAS
(1+1) * 4 / 2 --> 2 * 4 / 2 --> 8 / 2 --> 4
I remember both acronyms.. oops. one is wrong... I'm going loopy looking at it... both come out the same. uuuh.. i know there is a precedent order... aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaargh!
anyway....
off to code more! finish the vm, then do the compiler later
virtual cpu
virtual cpu
-- Stu --
Re:virtual cpu
These will probably help you with the C compiler, if you haven't already visited.
http://www.lysator.liu.se/c/ANSI-C-grammar-l.html
http://www.lysator.liu.se/c/ANSI-C-grammar-y.html
good luck. probably easier to write a compiler for a system that has a stack.
- Nick
http://www.lysator.liu.se/c/ANSI-C-grammar-l.html
http://www.lysator.liu.se/c/ANSI-C-grammar-y.html
good luck. probably easier to write a compiler for a system that has a stack.
- Nick
Re:virtual cpu
yeah. lucky I have a stack register windows and stuff, i dont like. i'm a stack man... hmm..
nick, hows the agi compiler going?
nick, hows the agi compiler going?
-- Stu --
Re:virtual cpu
besides pointers, everything is done.. with extra stuff like switches. Just need support in a stduio
- Nick
- Nick
-
- Member
- Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
Re:virtual cpu
you guys are da(*)mn cool.
I am struck with management of real time processes. crap though that is i dont get it work. ****.
I am struck with management of real time processes. crap though that is i dont get it work. ****.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
BlueillusionOS iso image