CHMK Macro

All the system calls that are available to us in the simulator are called through the CHMK macro. What the macro takes as a parameter is the number that corresponds to the macro that you want to perform. The actual parameters for the function have to exist in a parameter block, whose address has previously been loaded into the AP (argument pointer).

The contents of the block is specified in the "VAX MACRO Miscellany" manual (we have a copy of it on the course webpage). Each of the parameter blocks have, as their first parameter, the number of parameters in the block. The rest of the parameters are specified in the documentation.

So, to figure out how to call the exit macro, the documentation tells us that: Name: exit Code: 1 Parameters: status Parameters: termination status. Return values: none. Synopsis: Terminates execution of the program. A status of zero indicates normal termination; any other status indicates abnormal termination.

What this all means is that you need to create a block with 2 values (one is the number of parameters, and the 2nd is the termination status). Then you call the CHMK macro with the code of 1 (meaning you are performing an exit.

Looking back at Lab1, they set up a parameter block labeled OK as the block for the exit call:

Note that PARAMS_1, and ERROR_0 were perviously set up as assembler directives by the lines:

Then they set up the argument pointer with the line:

And then immediated called the CHMK macro with:

where EXIT is another assembler directives defined as:

Note that EXIT has the value of 1, which if we look at the documentation is the code for the exit macro.

If you go back and look at the other uses of CHMK in lab1 you will see them following the same 3 steps:

  1. set up param block (this can be done anywhere)
  2. load address of param block into AP
  3. calling CHMK with the code of the macro they are doing.