Micro­power

  

Volume 2, Number 3 – July 1982

Page 23 of 37

C contains the checksum for the data, and HL points to the next byte following the data. Note that if B is zero on entry, 256 bytes will be output.

SCAL XOUT, DF 6E

XOUT provides facilities for communication with external serial devices. On entry the contents of the accumulator are saved on the stack and HL is set to point to $XOPT (£0C28), which is the byte used to store the flags for the various options available with XOUT. The value stored at $XOPT is controlled by the X command; it is also affected by characters input via the XKBD routine.

The state of bit 7 of XOPT is first tested. If bit 7 is 1, the character is not output and the routine terminates by resetting bit 7 to zero (so that only one character at a time is suppressed) and recovering the accumulator from the stack. If bit 7 is zero, the character is output by a call to an external serial output routine , XSOP, before the routine is terminated as above.

XSOP outputs the character in the accumulator by a relative call to a subroutine, XSOP0. Here the accumulator is ORed, which sets the zero flag if the accumulator contained a null (00). In Nas-Sys 1 the subroutine is terminated if a null is found; thus the Nas-Sys 1 External output routine will not send nulls. In Nas-Sys 3 however the Return on Zero instruction has been omitted, and nulls can be output.

A second effect of the OR A instruction which starts XSOP0 is to set the parity/​overflow flag if the number of bits in the accumulator which are ‘1’ is even; otherwise the parity/​overflow flag will be reset. If the parity of the accumulator was odd, the output routine now changes the state of bit 7; the result is that the accumulator now contains a code of even parity, the bottom seven bits (bits 0 – 6) representing the ASCII character to be output.

Next bit 0 of £0028, the external option byte, is tested; if this bit is zero, the character is to be output with even parity, and the routine jumps straight to the final section, where SRLX is called. However, if bit 0 of £0028 was 1, bit 7 of the accumulator is first inverted, so that all output is of odd parity.

After return from subroutine XSOP0, the routine is terminated, unless the character that has just been output was a Carriage return. In this case, bit 4 of the option byte is checked, and if it is zero the accumulator is loaded with the line feed code (£0A); this is then output by a ‘fall through’ to XSOP0.

Page 23 of 37