VM Exit MessageIndex

Description:

A VM will terminate program execution when it executes an exit opcode, receives a cmdVM_KILL command, or detects an error.  Upon termination, the VM will send a message to the host.

The VM Exit Message is a cmdMSG (0x80) byte, followed by the vmExit identifier 0x1A, followed by the process ID, followed by the exit code which indicates the cause of the termination, followed by any data returned by the program.  A VM exit message will contain at least 4 bytes of data.  It may contain up to 6 bytes of data if the program returns a value.

If a program is declared with a return value and the program terminates normally, the return value will be appended to the VM exit message.  A program may return no bytes, one byte, or two bytes.  The number of return bytes is determined by the user.  If the program terminates abnormally due to an error, it will not return a value even if one was declared by the user.

The unique codes for each cause of program termination are listed below.  These message codes are defined in the file "aTEA.h" which may be found in the aInclude subfolder of the BrainStem SDK or C Development download.

Exit Code Alias Cause
0 aVMExitNormal A VM executed an EXIT opcode.
1 aVMExitKill A VM received a cmdVM_KILL command.
2 aVMExitStackUnderflow A VM attempted to execute an operation that would result in stack underflow.
3 aVMExitStackOverflow A VM attempted to execute an operation that would result in stack overflow.
4 aVMExitStackError A VM attempted to execute an illegal stack indexing operation.
5 aVMExitAddressRange A VM tried to access an illegal address.
6 aVMExitDivByZero A VM attempted to divide by zero.
7 aVMExitIOErr A VM attempted an IO operation with an invalid memory address.  A VM attempted to write to a read-only device.  A VM attempted to read from a write-only device.  A VM attempted to write an invalid parameter.
8 aVMExitBadOpcode A VM attempted to execute an invalid instruction.
9 aVMExitBadStartup A VM attempted to run with an invalid number of input bytes.
10 aVMExitBadVersion A VM attempted to run a program file with an with an incompatible version.
11 aVMExitBadCode A VM attempted to run a program file with an improper binary format.
12 aVMExitBadRetVal A VM attempted to return a data type of the wrong size.
13 aVMExitBadCommand A VM attempted to execute an improperly formatted command.

version: 1.0, build 80903
© Copyright 1994-2008 Acroname, Inc., Boulder, Colorado.  All rights reserved.