Qbasicnews.com

Full Version: Byte code engine... need a bit help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I was thinking about writing a bytecode script engine in qbasic for my fakeOS what I'm trying to write. But right now I'm trying to get some idea about what I'm going to do. Here's my idea:

Script language what will be compiled into byte code would be very asm like, with some exceptions/limitation and etc... The point of it would be that this code I could compile into call absolute ready code. So later when executing this all I would have to do is send it through call absolute. I think that this way it would be as fast as it can go.

The problem would be of course other specific commands(like in fake os calling for a window for example) can't be done in this asm. So my idea is that byte code would have blocks of code. If certain byte in block is 1 or 0 then send it either to call absolute or to internal interpreter.

What I want to know, that is this worth trying and spending effort on. What would be possible problems or so on.

Please, I'd be apprecieted.
Well,
I have no clue how to do that, but u should get ahold of Z!re, since he's doing Novix...im not sure if hes doing byte code, or if even has a clue what it is, but its worth a shot.

Oz~
I'm using bytecoded scripts, and VonGodric has already been on me, I think he's looking for additional suggestions/help =)


Possible problems include such things as: Infinite loops, Corrupted memory, Register Switching etc etc...

It's a mess, better off just making it interpreted, for start, and then later add the call absolute things

Like I've said before... =)





Bytecode is when, instead of:
PRINT "Blarg"

You have something like:
one byte for PRINT, and then either the string (with header for lenght) or an offset into memory where the string is loaded.

Bytecode is smaller, and faster, it's also easier to make certain things in it, for example GOTO/JUMP's
Try doing a stack based machine first, they are generally easier to implement and are even used in real VM's such as JVM and the .NET VM. If you want to add to numbers, then you load both of there values onto the stack, and do an add instruction which adds the top two values of the stack together, pops them both and pushes the answer. You can use a basic heap structure (flat array) for storing things like variables and strings. At the very least you will probably want instructions like: load (heap to stack), store (stack to heap), add, sub, mult, div, cmp (compare, operand for comparasion type), jpc (conditional jump) and jmp.

To handle more complex things such as your fakeOSes window handling etc, you just have a system call operation. The operands could be used to specify the call type and position and length of the system call arguments in the heap. When your VM encounters the syscall operation, it grabs the arguments and then passes it all to the correct handler in your fakeOS.
tnx guys.

Now when I have thought about it myself, it would just couse more problems then it's worth. Oh well, but I Think I'll follow your idea LooseCaboose.