I put some useful subprograms of the monitor here. These subpograms
are of special interest to people writing applications in machine code.
The routines can be used by the assembler command CALL followed
by the entry point address.
The contents of the registers shown by "Protected registers" in the following descriptions will remain unchanged by the associated subprogram, while the contents of registers not shown must be saved first if necessary by the use of the assembler command PUSH reg prior to the call of the subprogram and must be restored by the assembler command POP reg when the subprogram terminates.
Inputs one line of text from the keyboard.
Specify the start address of the RAM location for storing data in the Z80 register pair DE before entry to the routine.
The end of text string marker is a CR ( 0ドルD ) character. The maximum number of characters in the input string is 80 including the CR at the end of the string.
Note, key input is echoed to the V.D.U. screen. Cursor control characters are allowed in the string.
When the SHIFT and BREAK keys are pressed the BREAK code is entered in RAM at te address speified by the contents of DE. A CR is also entered address (DE)+1.
Note, all registers are stored on entry to this routine and 15 stack levels are rquired.
This routine outputs a CRLF to the V.D.U. screen and moves the cursor to the start of the next line.
All registers are stored except A and F. Also 8 stack levels are required by this routine.
This routine outputs a CRLF to the V.D.U. screen and moves the cursor to the start of the next line if the cursor is not at the first porsition of a line.
All registers are stored except A and F. Also 8 stack levels are required by this routine.
This routine outputs to the V.D.U screen one space character at the current cursor position.
All registers are stored except A and F. Also 13 stack levels are equired by this routine.
This routine outputs the ASCII code for a character stored in accumulator A to the current cursor position on the V.D.U. screen. If the contents of A is a carriage return ( CR, 0ドルD ) character a carriage return is displayed on the V.D.U. Similarly cursor control codes 11ドル o 16ドル cause movement of the cursor ( up, down, left, right, home, clear ).
All registers are store except A and F. Also 13 stack levels are required by this routine.
Outputs a message on the V.D.U screen starting at the current cursor position.
The address of the start of the message in RAM is entered in the Z80 DE register pair before entry to the routine.
The message must be a string of ASCII characters terminated by an 0ドルD character.
Note The carriage return character at the end of the message string is NOT executed.
However, cursor control characters are executed. See the table at 0012ドル.
All registers are stored. Also 14 stack levels are required by this routine.
Inputs to accumulator A the ASCII code of a key which has been pressed.
The code for the pressed key is NOT echoed to the V.D.U. display drive.
Note Key bounce is not prevented by this routine.
Value in
register A
All registers other than A and F are stored. Also 9 stack levels are required by this routine.
This routine plays music, executing a string of ASCII data characters to generate the sound sequence.
Specify the start address of the music data string in the Z80 register pair DE before entering the routine.
The music data is a string which is arranged as a sequence of pitch and duration ASCII control codes. The string sequence is the same as that shown in the SHARP BASIC Manual. The end of string marker should be an 0ドルD or $C8 character.
On returning from the subroutine the Z80 register C is set to 0 if the music sequence was completed or C is set to 1 if not completed, due to the BREAK key having been pressed while the music was playing.
All registers other than A and F are stored. Also 7 stack levels are required by this routine..
This routine sets the built-in real time clock.
Note The clock is started by a call to this routine !
The clock is set to the contents of the following registers:
The contents of A and DE must be set before entering this routine.
All registers are stored other than A, F, and DE. Also 6 stack levels are required by this routine.
This routine reads the time from the real time clock.
The Z80 internal registers hold the real time. To this see the table at routine 0033ドル.
All registers except AF and DE are stored. Also 3 stack levels are required by this routine.
This routine simulates the ringing of a bell. A middle A note ( ruoghly 440Hz ) is generated for a short time.
All registers are stored other than AF. Also 5 stack levels are required by this routine.
This routine sets the tempo of the music generator.
The value ( 1 to 7 ) of the tempo must be set entered into the Z80 accumulator register A before calling this routine.
NoteThe codes set into the accumulator A are in binary NOT ASCII characters.
This routine generates a sound specified by the relation
f = 2000 kHz / nn'
nn' is a 2 bytes hex value to be stored into the storage at locations 11ドルA1 and 11ドルA2. n is the high order byte and must be stored into location 11ドルA2 and n' is the low order byte and must be stored into location 11ドルA1.
Both values must be stored before calling this routine.
Note Yyour program must stop the tone by the following subroutine 0047ドル or by your own subroutine before your program invokes the next tone otherwise an unpredictable frequency value is invoked.
Note nn' must be greater than 255 !
Example:
A continous tone of 100 Hz is to invoke.
nn' = 1108.8 kHz / f ( f = 100 Hz )
nn' = 1108.8 * 103 Hz / 100 Hz = 11,088
11.088 is to convert into hex, that is 2ドルB50 and this value is to load into 11ドルA1 / 11ドルA2.
;load counter value 1200 21502B LD HL,2ドルB50 ;into memory 1203 22A111 LD (11ドルA1),HL ;start tone of 100 Hz 1206 CD4400 CALL 0044ドル ;goback to monitor 1209 C3AD00 JP 0082ドル
At this point a tone of 100 Hz is audible. To stop the tone use the subroutine 0047ドル.
Registers BC and DE are stored. Also 3 stack levels are required by this routine.
This routine stops the operation of the sound generator and it is initialized for a next operation by 0044ドル.
All registers are stored except AF. One stack level is required by this routine.
This routine takes the lower 4 bits of the contents of the accumulator and converts it into an ASCII code. The resulting code is entered into A before leaving the routine.
All registers are stored except AF. Three stack levels are required by this routine.
This routine performs the reverse function of the routine at 03ドルDA.
The 8 bits of accumulator A are assumed to represent an ASCII code. This code is converted into a hexadecimal number. The resulting number is stored in the accmulator before leaving the routine.
If the carry flag is 0 on returning to the calling routine the number in the accumulator is a hexadecimal number.
All registers are stored except A and F and HL. Three stack levels are required by this routine.
This routine converts a four character ASCII string into a hexadecimal number. The hexadecimal number is stored in register HL.
Before calling this routine the address in RAM of the start of the ASCII string must be entered in registered pair DE, for example : "3", "1", "A", "5" ( ASCII string pointed to by DE ). Then HL will be 31ドルA5.
If the carry flag is 0 on returning to the calling routine the number in HL is hexadecimal.
All registers are stored except AF and HL. 7 stack levels are required by this routine.
Similar to the routine at 0410ドル . Converts two character ASCII string pointed to by DE to hexadecimal and sets result in accumulator A.
If the carry flag is 0 on returning to the calling routine the number in A is hexadecimal.
All registers except AF and DE are stored. 5 stack levels are required by this routine.
While flickering the cursor this routine waits for a key to be pressed. When a key is pressed it sets the display code for the key in accumulator A and returns.
All registers except AF are stored. 11 stack levels are required by this routine.
This routine converts an ASCII string in accumulator A into its display code.
The accumulator is set to $F0 for non-displayable characters.
All registers except AF are stored. 3 stack levels are required by this routine.
This routine converts a display code stored in accumulator A into its ASCII code.
Note By a bug in the monitor the result is unusable if the register A contains a display code greater than 223.
All registers except AF are stored. 3 stack levels are required by this routine.
This routine may be used to control the display on the V.D.U. screen. The value of accumulator A determines the controlling function. To this, see the following table.
All registers are stored. 9 stack lvels are required by this routine.
This routine determines the current position of the cursor on the V.D.U. screen.
The cursor position is stored as a binary number in the Z80 registaer pair HL.
Remember, there are 25 lines of 40 characters, yielding 1,000 possible positions between 0 and 999.
All registers are stored except AF and HL and 5 stack levels are required by this routine.
Go to the top of this page
Home
last updated September 1, 2002
[email protected]