Next: , Previous: , Up: Using mixguile   [Contents][Index]


3.4.2 Additional MIX Scheme functions

The mix- function counterparts of the mixvm commands don’t return any value, and are evaluated only for their side-effects (possibly including informational messages to the standard output and/or error stream). When writing your own Scheme functions to manipulate the MIX virtual machine within mixguile (see Defining new functions), you’ll probably need Scheme functions returning the value of the registers, memory cells and so on. Don’t worry: mixguile also offers you such functions. For instance, to access the (numerical) value of a register you can use mix-reg:

guile> (mix-reg 'I2)
0
guile>

Note that, unlike (mix-preg 'I2), the expression (mix-reg 'I2) in the above example evaluates to a Scheme number and does not produce any side-effect:

guile> (number? (mix-reg 'I2))
#t
guile> (number? (mix-preg 'I2))
rI2: + 00 00 (0000)
#f
guile>

In a similar fashion, you can access the memory contents using (mix-cell), or the program counter using (mix-loc):

guile> (mix-cell 3000)
786957541
guile> (mix-loc)
3002
guile>

Other functions returning the contents of the virtual machine components are mix-cmp and mix-over, which eval to the value of the comparison flag and the overflow toggle respectively. For a complete list of these additional functions, See mixguile.

In the next section, we’ll see a sample of using these functions to extend mixguile’s functionality.