Messages

Messages are mechanism that allows NoSense programs to interact with devices. There are input and output messages. They work in two different ways.

Output messages

Despite their names, output messages can be used to output information to the devices, as well as to obtain information from them. The important thing is that they are called by the program.

To use an output message:

  1. Save device number in A1 register
  2. Save message type in A2 device
  3. Save message parameters in other registers
  4. Call OUT instruction
  5. Check whether operation succeeded on the basis of registers
  6. Get returned information from registers

Sending output message can change only registers that are mentioned as output parameters for the particular message type.

Input messages

Input messages are generated by devices and placed in the input message queue. This queue saves order of messages that got in into it. New messages are added to the back and the oldest messages are read and removed from the front of the queue.

You should always keep processing input messages to prevent the situation that queue will become full and messages will be lost. To handle an input message:

  1. Prepare:
  2. Save registers on the stack if they contain any significant information
  3. Call IN command
  4. Check the sender device in A1 register (0 means that there is no input message)
  5. Check the message type in A2 register
  6. Read message parameters from other registers

Remember that getting input message can change all the universal registers.