Sharp logo
The monitor program SP-1002 
( A short description of the subprograms )  


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.

 
Location Symbolic
name
used
register(s)
Stack
levels
Description
$0000
MONIT all - This is the first address executed if the power is turned on or if the reset key is pressed. Monitor cold start entry point.
$0003
GETL - 15

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 ( $0D ) 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.

$0006
LETNL AF 8

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.

$0009
NEWLIN AF 8

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.

$000C
PRINTS AF 13

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.

$000F
TABUL AF 14 Skip to column 10, 20, 30,
$0012
PRNT AF 13

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, $0D ) 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 ).

Cursor
control
code
Cursor
movement
$0D CR
$11 Cursor down
$12 Cursor up
$13 Cursor right
$14 Cursor left
$15 HOME
$16 CLR
$7F Scroll

All registers are store except A and F. Also 13 stack levels are required by this routine.

$0015
MSG - 14

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 $0D 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.

$0018
LISTL - 14 Works like the routine at location $0015, but the symbols of cursor control characters are displayed ( not executed ! ).
$001B
GETKY AF 9

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.

Key

Value in
register A

DEL $60
INST $61
CAP $62
SML $63
BREAK $64
CR $66

All registers other than A and F are stored. Also 9 stack levels are required by this routine.

$001E
BRKEY AF 1 If SHIFT and BREAK are pressed the zero flag is set to indicate this event.
$0021
WOPEN AF 21 This routine writes the tape header from location $10F0 to tape. See the description of the monitor's workarea.
$0024
WRITE AF 21 This routine writes data to tape.
$0027
ROPEN AF 21 This routine reads the next tape header into the RAM beginning from the location $10F0. See the description of the monitor's workarea.
$002A
READ AF 21 This routine reads the data from the file into the RAM beginning from the location as defined in the tape header. See the description of the monitor's workarea.
$002D
VERIFY AF 21 Compare the data written to tape with the data in the RAM to be sure that the tape file will be ok.It checks data on cassette tape BUT does not store it into RAM - just compares data on tape with contents of RAM.
$0030
MELDY AF 7

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 $0D 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..

$0033
TIMST AF 6

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:

Register meaning
A = 0 AM
A = 1 PM
DE time in seconds
( 2 bytes binary )

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.

$003B
TIMRD AF, DE 3

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.

$003E
BELL AF 5

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.

$0041
XTEMP - 4

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.

Register A Tempo
$01 slowest tempo
$04 medium tempo
$07 fastets tempo

NoteThe codes set into the accumulator A are in binary NOT ASCII characters.

$0044
MSTA AF, HL 3

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 $11A1 and $11A2. n is the high order byte and must be stored into location $11A2 and n' is the low order byte and must be stored into location $11A1.

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 $2B50 and this value is to load into $11A1 / $11A2.

;load counter value
1200 21502B   LD   HL,$2B50
;into memory
1203 22A111   LD   ($11A1),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.

$0047
MSTP AF 1

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.

$0082
ST1 - - Warm start address of the monitor.
$0180
CMPSTR AF 4 This routine compares strings: The start addresses of the strings must be stored into DE and HL and the length into B prior of the exexution of this subroutine. The zero flag is set to 0 to indicate that the strings are equal.
$02AE
TONE AF, HL 3 Works like $0044 but you can store nn' into HL.
$03BA
PRTWRD AF 16 This routine outputs a 16-bit hexadecimal number contained in HL to the screen.
$03C3
PRTBYT AF 15 This routine outputs a hexadecimal number contained in A to the screen.
$03DA
DIGASC AF 3

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.

$03F9
ASCDIG AF 3

This routine performs the reverse function of the routine at $03DA.

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.

$0410
ASCWRD AF, HL 7

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 $31A5.

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.

$041F
ASCBYT AF, DE 5

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.

$08CA
GETKYD AF 8 This routine reads a character from the keyboard into the accumulator. The character is in display code format. If no key was pressed the accumulator contains $F0. It doesn't wait for input.
$0946
PRTCH AF 10 The ASCII character contained in C is displayed on the screen. The routine does not wait for the blanking signal. The carriage return character $0D takes no action. This routine works similar to the routine $0012.
$0970
DISPLY AF 10 The display code contained in the accumulator A is displayed on the screen. The routine does not wait for the blanking signal.
$09B3
READKY AF 11

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.

$0A44
BRKTST AF 1 This routine checks if the break key is pressed. If the break key is pressed the zero flag is set.
$0BB9
ACDISP AF 3

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.

$0BCE
DISPAC AF 3

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.

$0DA6
SNCV - 2 Waits for the blanking signal. Access to the video-RAM without interferences is possible by using this routine.
$0DB5
DISPCH - 9 Works similar to the routine at $0970 but the column counter of the tabulator ( UP TABUL $000F ) will not be incremented by this routine.
$0DDC
MOVECU - 9

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.

accu function
$C0 scrolling
$C1 cursor down
$C2 cursor up
$C3 cursor right
$C4 cursor left
$C5 HOME
$C6 CLR
$C7 DEL
$C8 INS
$C9 CAP
$CA SML
$CD CR

All registers are stored. 9 stack lvels are required by this routine.

$0FB1
GETVAD AF, HL 5

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.

$0FB4
CALVAD HL 4 Computes the V-RAM address of the current cursor position. L = column; H = row. The result is stored into the register pair HL.
$0FC9
INITIO AF, HL 1 Inits the 8255: Mode 0, ports A and C0 - C3 are set as output ports; ports B and C4 - C7 are set as input ports.


Go to the top of this page Home

last updated September 1, 2002
sharpmz@sharpmz.org