Next: Hooks, Previous: Scheme functions reference, Up: Scheme functions reference
mixvm
command wrappersFor each of the mixvm
commands listed in Commands, there is
a corresponding Scheme function named by prefixing the command name with
mix-
(e.g., mix-load
, mix-run
and so on). These
command wrappers are implemented using a generic command dispatching
function:
Dispatchs the given command to the MIX virtual appending the provided argument. Both command and
argument
must be strings. The net result is as writing "command argument" at themixvm
orgmixvm
command prompt.
For instance, you can invoke the run
command at the mixvm
prompt in three equivalent ways:
MIX > run hello MIX > (mix-run "hello") MIX > (mixvm-cmd "run" "hello")
(only the two last forms can be used at the mixguile
prompt or
inside a Scheme script).
The mix-
functions evaluate to a unspecified value. If you want
to check the result of the last mixvm
command invocation, use the
mix-last-result
function:
Returns #t if the last
mixvm
command invocation was successful, #f otherwise.
#! /usr/bin/mixguile \ -e main -s !# ;;; Execute a given program and print the registers. (define main (lambda (args) ;; load the file provided as a command line argument (mix-load (cadr args)) ;; execute it if mix-load succeeded (if (mix-last-result) (mix-run)) ;; print the contents of registers if the above commands succeded (if (mix-last-result) (mix-pall))))
Please, refer to Commands for a list of available commands. Given
the description of a mixvm
, it is straightforward to use its
Scheme counterpart and, therefore, we shall not give a complete
description of these functions here. Instead, we will only mention those
wrappers that exhibit a treatment of their differing from that of their
command counterpart.
The argument register of these functions can be either a string or a symbol representing the desired register. For instance, the following invocations are equivalent:
(mix-preg 'I1) (mix-preg "I1")
The command
pmem
takes a single argument which can be either a cell number or a range of the formFROM-TO
. This function takes one argument to ask for a single memory cell contents, or two parameters to ask for a range. For instance, the following commands are equivalent:MIX > pmem 10-12 0010: + 00 00 00 00 00 (0000000000) 0011: + 00 00 00 00 00 (0000000000) 0012: + 00 00 00 00 00 (0000000000) MIX > (mix-pmem 10 12) 0010: + 00 00 00 00 00 (0000000000) 0011: + 00 00 00 00 00 (0000000000) 0012: + 00 00 00 00 00 (0000000000) MIX >
The command
sover
takes as argument either the stringT
or the stringF
, to set, respectively, the overflow toggle to true or false. Its Scheme counterpart,mix-sover
, takes as argument a Scheme boolean value:#t
(true) or#f
.
For the remaining functions, you simply must take into account that when the command arguments are numerical, the corresponding Scheme function takes as arguments Scheme number literals. On the other hand, when the command argument is a string, the argument of its associated Scheme function will be a Scheme string. By way of example, the following invocations are pairwise equivalent:
MIX > load ../samples/hello MIX > (mix-load "../samples/hello") MIX > next 5 MIX > (mix-next 5)