Previous: , Up: Getting started   [Contents][Index]


3.5 Using Scheme in mixvm and gmixvm

In the previous section (see Using mixguile) we have seen how the Guile shell mixguile offers you the possibility of using Scheme to manipulate a MIX virtual machine and extend the set of commands offered by mixvm and gmixvm. This possibility is not limited to the mixguile shell. Actually, both mixvm and gmixvm incorporate an embedded Guile interpreter, and can evaluate Scheme expressions. To evaluate a single-line expression at the mixvm or gmixvm command prompt, simply write it and press return (the command parser will recognise it as a Scheme expression because it is parenthesized, and will pass it to the Guile interpreter). A sample mixvm session using Scheme expressions could be:

MIX > load hello
Program loaded. Start address: 3000
MIX > (define a (mix-loc))
MIX > run
Running ...
MIXAL HELLO WORLD
... done
Elapsed time: 11 /Total program time: 11 (Total uptime: 11)
MIX > (mix-pmem a)
3000: + 46 58 00 19 37 (0786957541)
MIX > (mix-pmem (mix-loc))
3002: + 14 09 27 01 13 (0237350989)
MIX >

You can also load and evaluate a file, using the scmf command like this:

MIX> scmf /path/to/file/file.scm

Therefore, you have at your disposal all the mixguile goodies described above (new functions, new command definitions, hooks...) inside mixvm and gmixvm. In other words, these programs are extensible using Scheme. See Using mixguile for examples of how to do it.