Micropower |
Volume 2 · Number 2 · April 1982 |
Page 9 of 37 |
---|
the keys in row 0 are read in the standard way.
This input routine picks up the address of the input table from the workspace at £0C75; this table contains a series of numbers representing Nas-Sys subroutines, and these are called in turn until a zero entry is reached. The address at £0C75 normally points to a table which contains two subroutines, the keyboard input and serial input, but it can be reset by the U or the X commands, or it can be changed by the user to point to a table of his own. In Nas-Sys 1 the keyboard routine in the input table is DF 61, but in Nas-Sys 3 it is the repeat keyboard routine, DF 7D, which itself calls DF 61 as a subroutine.
This routine calls SCAL 7B, which blinks the cursor while waiting for a key to be pressed. When a key is pressed the character is printed and if it was not a carriage return the routine loops back to SCAL 7B. When a carriage return is detected, the current address of the cursor, which was moved to the start of the next line by the carriage return, is loaded into HL from £0C29, DE is set to −64, HL and DE are added together and interchanged, and the subroutine is terminated. The result is that on return DE contains the address of the start of the line which the cursor was on when carriage return was pressed.
This routine converts a single string of hex characters into a sixteen bit number. On entry the DE register pair should point to the start of the string, although leading blanks are ignored. As each character is obtained from the string it is tested for validity (i.e., is it ASCII 0 – 9 or ASCII A – F). If an invalid character is detected the carry flag is set and the routine ends. Each valid character is converted to a binary number in the range 0 – 15, counted in location £0C20, and the four bit value is rotated left into £0C21, using the instruction RLD (Rotate Left Decimal). This instruction transfers the bottom four bits in the accumulator into the bottom four bits of (HL), the bottom four bits in (HL) are transferred into the top four bits, and the top four bits of (HL) are transferred back to the bottom four bits of the accumulator. The HL register pair is now incremented and the RLD instruction repeated. The result is that the characters in the string are successively converted into a sixteen bit number in NUMV. If the number overflows on the second RLD instruction, this indicates that the hexadecimal string represented a number greater than £FFFF, the carry flag is set, and the routine terminates. When the end of the string is encountered, marked by a space character or a null character (screen margin) the routine returns with the carry flag reset, the value of the string in NUMV,
Page 9 of 37 |
---|