[virtmach] first VM.
Tom Fjellstrom
tfjellstrom@home.com
Fri, 10 Nov 2000 20:00:31 -0700
Mitch Wright wrote:
>
> A
> >> Now, if you intend to expand your VM past 255 instructions (sounds far
> >> fetched now, but what about 6 months down the line) then creating your own
> >> jump table, or using a table of functions pointers may be more efficient.
> >
> >Really? So a big switch/case is slower than a huge amount of function
> >calls?
> >by the way, what is a jump table? Or better yet, how is one implemented?
> >(I learn better by example, theory usually just seeps back out of my
> >head.)
>
> More Food: http://www.complang.tuwien.ac.at/forth/threaded-code.html
>
> Check out topic on: GNU C's Labels as Values
>
Thank you!
I've had a look at the link you gave and I have a question:
Would the instruction call table creation time override the
benefits of either the Call Threading, or the
Continuation-passing style techniques?
Currently my virtual machine just reads the binary data
*one byte at a time from 'memory' and goes to the switch
statement to execute the instructions.
(one big fetch->execute cycle)
* actually its not really one byte but the first byte of
an instruction is the opcode for that instruction then
comes the optional argument bytes which start with 1 byte
telling the 'fetch' macro that the argument is a memory
reference (pointer), another byte for the type
(literal, register, memory...) and the next 4 bytes
is the argument itself (LSB).
An instruction can have 0 to 2 arguments.
Thanks again,
--
Tom Fjellstrom
tfjellstrom@home.com
http://strangesoft.net/