Sharp logo
The monitor program MZ-1Z013A 
( A short description of the subprograms )  


I put some useful subprograms of the monitor here. These subprograms 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.

Entrypoint $0000
Function start monitor
Symbolic name MONIT
Protected registers none
Description

This is the entry point to the monitor program after resetting the MZ-700 or after switching the power on.

Invoking this subroutine will take the same effect like pressing the RESET key: the MZ-700 restarts. Note, the workarea will be cleared and some other functions are performed too. To this see the monitor's source code ( 50KB ).

This entry of the monitor program may be used by a CALL instruction but no control will be given back to the caller. There will be no difference between using a CALL instruction or a JP instruction in your program to go to this entry. An example using this entry follows.

To modify something in the monitor's code the ROM is to copy to the RAM and then the monitor program is to restart:

B000 210000   LD   HL,$0000 ;copy from ROM $0000
B003 110012   LD   DE,$1200 ;to RAM $1200
B006 010008   LD   BC,$0800 ;in the length of $0800
B009 EDB0     LDIR          ;do the copy now
B00B D3E0     OUT  ($E0),A  ;bank switch ROM to RAM
B00D 210012   LD   HL,$1200 ;and copy from RAM $1200
B010 110000   LD   DE,$0000 ;to RAM $0000
B013 010008   LD   BC,$0800 ;in the length of $0800
B016 EDB0     LDIR          ;do copy
B018 C30000   JP   $0000    ;go to monitor (reset)

First the monitor's ROM is to copy into any RAM location. I have chosen the RAM area from $1200 to $19FF. Use another location if needed. The move will be done by the instructions at locations $B000, $B003, $B006, and $B009.

When the copy is completed the ROM area must be switched to the RAM area ( done by the instruction at location $B00B ). The contents of the ROM previous copied to the RAM up from location $1200 can be removed now to its executable location up from $0000 but in the RAM ( $B00D, $B010, $B013, and $B016 ). Then the monitor in the RAM will be executed by the instruction at location $B018.

The monitor exists now in the RAM, executes in the RAM, and can be modified for own purposes by the command M. This area can be saved every time if needed by the monitor's command L. Follow the previous links for a detailed description of the commands M or L.


Entrypoint $0003
Function get line
Symbolic name GETL
Protected registers all
Description

This subroutine waits for a keyboard input string up to max. 80 characters in length.

The characters typed in will be stored starting up from the memory location specified by the register DE. The register DE must point to an input area of 80 bytes in length and must be established before calling this subroutine.

The execution of this routine stops by pressing CR or by pressing SHIFT and BREAK coincidentally.

If the CR key is used the string entered will be suffixed by $0D. If no string was entered but the CR key, then the key code of CR ( $0D ) only is placed in the input area addressed by DE.

If SHIFT andBREAK were pressed coincidentally then the input area contains the break key code $1B followed by the CR key code $0D, so any program can take effect to this condition.

Because all registers are protected / saved by this subroutine no information about the length of the character string that was entered is available on return from this subroutine. If the caller of this subroutine needs the length of the input string all characters must be counted until the key code $0D in the input area will be found. This is done by the following example.

Example:

B000 1100C5      LD   DE,$C500 ;at $C500 is my input area 80 bytes
                               ;in length
B003 CD0300 NON: CALL $0003    ;execute monitor's GETL subroutine
B006 1A          LD   A,(DE)   ;get 1st character of string if any
B007 FE1B        CP   $1B      ;check for break key code
B008 CAxxxx      JP   Z,BREAK  ;if break go to the BREAK routine
B00B FE0D        CP   $0D      ;check if none input
B00D CAxxxx      JP   Z,NONE   ;I don't allow no input, again user
B010 0600        LD   B,$00    ;init counter of string length
B012 FE0D   CNT: CP   $0D      ;end of string?
B014 2805        JR   Z,STRE   ;yes, go to process string.
                               ;B contains length of the string
B016 04          INC  B        ;counter + 1
B017 13          INC  DE       ;address to next character
B018 1A          LD   A,(DE)   ;get it
B019 18F7        JR   CNT      ;check next character

B01B       STRE:    ;at this point I can process the string

Subroutine BREAK not shown.


Entrypoint $0006
Function 2 new lines
Symbolic name LETNL
Protected registers all except AF
Description

This subroutine sets the cursor to the first column of the line after the next line ( spaces 1 line ).

Example:

B000 CD0600   CALL $0006 ;new line
B003 C3AD00   JP   $00AD ;goback to monitor

No more instructions were needed.


Entrypoint $0009
Function new line
Symbolic name NL
Protected registers all except AF
Description

This subroutine sets the cursor to the first column of the next line.

Example:

B000 CD0900   CALL $0009 ;new line
B003 C3AD00   JP   $00AD ;goback to monitor

No more instructions were needed.


Entrypoint $000C
Function print space
Symbolic name PRNTS
Protected registers all except AF
Description

This subroutine prints a space character at the current cursor position.

Example:

B000 CD0C00   CALL $000C ;print single space character
B003 C3AD00   JP   $00AD ;goback to monitor

No more instructions were needed.


Entrypoint $000F
Function print TAB
Symbolic name PRNTT
Protected registers all except AF
Description

This subroutine sets the cursor to the next tabulator position depending on the current cursor position. Tabulator positions are the columns 1, 11, 21, and 31.

For example, if the current cursor position is 25 then the cursor will be set to column 31. The next output of a print command starts printing at column 31.

Example:

B000 CD0F00   CALL $000F ;set cursor to next tab position
B003 C3AD00   JP   $00AD ;goback to monitor

No more instructions were needed.


Entrypoint $0012
Function print character
Symbolic name PRNT
Protected registers all except AF
Description

This subroutine displays at the current cursor position the ASCII character stored in the accumulator register A .

The conversion from ASCII code to the display code will be done internally. Additional all cursor control characters will take effect to its associated function.

Example:

B000 3E16     LD   A,$16 ;force clear screen
B002 CD1200   CALL $0012 ;print clear screen
B005 3E43     LD   A,$43 ;load character "B"
B007 CD1200   CALL $0012 ;print character
B00A C3AD00   JP   $00AD ;goback to monitor

First the screen will be cleared by the instruction sequence from $B000 to $B002, then the letter "B" will be printed by $B005 and $B007.


Entrypoint $0015
Function print message
Symbolic name MSG
Protected registers all
Description

This subroutine displays a character string at the current cursor location. The string is contained in a memory area and the start of this area must be pointed to by the register DE .

The end of the character string must be indicated by the carriage return control character $0D, but no carriage return will take effect on the screen.

Any other cursor control characters $11 - $16 contained in the character string will take effect like pressing its associated key function ( e.g. cursor control keys or clear screen key ).

A new line function cannot be invoked by this subroutine. If a new line function is needed the message must be split into two print messages and the new line control function must be invoked between the print functions of the two messages.

Example:

B000 1100AF   LD   DE,$AF00 ;pointer to string 1
B003 CD1500   CALL $0015    ;print string 1
B006 CD0900   CALL $0009    ;new line
B009 1107AF   LD   DA,$AF07 ;pointer to string 2
B00C CD1500   CALL $0015    ;print string 2
B00F C3AD00   JP   $00AD    ;goback to monitor
 
AF00 16 46 49 52 53 54 0D 53  .FIRST.S
AF08 45 43 4F 4E 44 0D xx xx  ECOND... 

The register DE points to an ASCII string to be printed from the memory. The register DE will be established by the instruction at $B000 and the print function will be done by the CALL at location $B003.

First, the screen will be cleared by printing the control character $16 contained in the first position of the string. Next, the string "FIRST" at location $AF01 will be printed at the top of the screen. The CR control character at location $AF06 indicates the end of this string and will not be printed but the print function of this string will be terminated by this.

A new line will be printed by the CALL at location $B006. The string "SECOND" is addressed by the instruction at $B009 and printed out at this new line by the CALL at location $B00C. The print function ends by the CR at location $AF0D.


Entrypoint $0018
Function print message
Symbolic name MSGX
Protected registers all
Description

This subroutine displays a character string at the current cursor location. The string is contained in a memory area and the start of this area must be pointed to by the register DE .

The end of the character string must be indicated by the carriage return control character $0D, but no carriage return will take effect on the screen.

Any other cursor control characters $11 - $16 contained in the character string will be printed as a character ( e.g. cursor down = $11 is displayed as cursor down ), no other control character function is performed.

Example:

B000 1100AF   LD   DE,$AF00 ;pointer to string
B003 CD1800   CALL $0018    ;print string
B006 C3AD00   JP   $00AD    ;goback to monitor
 
AF00 16 44 45 46 47 48 0D xx  .DEFGH..

The register DE points to an ASCII string to be printed from the memory. First, the character $16 will be printed as Clear screen and no other control key function will be performed. Next, the string "DEFGH" at location $AF01 will be printed at the current cursor position.


Entrypoint $001B
Function get key
Symbolic name GETKY
Protected registers all except AF
Description

This subroutine scans the keyboard but it doesn't wait for any key input.

If no key was active the accumulator register A contains $00 on return to the caller, otherwise the accumulator register A contains the ASCII code of the associated key.

The code of an active key neither will be displayed on screen nor any control function ( e.g. clear screen ) will be performed.

The control keys return the following codes in the accumulator register A ( additional display code is shown for further information ):

Key(s) Contents of
the accumulator
register A
Display
code
cursor down
cursor down
$11 $C1
cursor up
cursor up
$12 $C2
cursor right
cursor right
$13 $C3
cursor left
cursor left
$14 $C4
home
Home position
$15 $C5
clear
Clear screen
$16 $C6
DEL $60 $C7
INST $61 $C8
ALPHA $62 $C9
GRAPH $63 $CA
SHIFT+BREAK $64 $CB
CR $66 $CD

Example:

B000 CD1B00   CALL $001B    ;get key
B003 C4C303   CALL NZ,$03C3 ;display key code if register A not $00
                            ;2 digits hexadecimal notation
B006 C300B0   JP   $B000    ;loop until hard reset

The keyboard will be scanned by CALL $001B. The contents of register A will be displayed at the current cursor position and will be shown in a 2-digits hexadecimal notation by a conditional CALL NZ,$03C3. The condition 'no key pressed' is suppressed by this call. That means $00 will not be displayed.

Note, this routine loops until the reset key is activated.


Entrypoint $001E
Function check control keys BRK / SHIFT / CTRL
Symbolic name BRKEY
Protected registers all except AF
Description

This subroutine tests if a control key or a combination of the SHIFT key and the BREAK key is pressed coincidentally but it doesn't wait for any key input.

If one or more of the control keys were used the zero flag is set ( Z = 1 ), otherwise it is reset ( Z = 0 ).

The following table will help to determine which key(s) is / are pressed:

Key(s) Contents of the
accumulator
register A
Carry
flag ?
Zero
flag ?
no key $7F no no
BREAK $3F no no
SHIFT $40 yes no
CTRL $20 yes no
SHIFT+BRK $00 no yes

Example:

This example determines which control key was used and invokes the associated routine.

B000 CD1E00           CALL $001E   ;check break
B003 CAxxxx           JP   Z,BRK   ;break condition
;                                  ;SHIFT and BREAK used
B006 DA00B1           JP   C,OTHER ;SHIFT or BREAK key used
B009 FE3F             CP   $3F     ;BREAK key pressed?
B00B CAxxxx           JP   Z,BRK   ;yes, break condition 2 allowed
B00E    ; at this point no control key was pressed
B00E    ; normal processing follows here.
 
; identify which key used, SHIFT or BREAK
B100 FE20     OTHER:  CP   $20     ;CTRL key?
B102 CAxxxx           JP   Z,CTRL  ;yes, do CTRL procedure
B105 C3xxxx           JP   SHIFT   ;no, do SHIFT procedure

Executing the subroutine $001E by a CALL $001E sets the zero flag, the carry flag, and the accumulator register as necessary. The zero flag is set only by pressing the SHIFT and BREAK keys, so this condition is noticed by the command JP Z,BRK.

The carry flag is set by pressing the CTRL key or the SHIFT key, further checks to determine which key was used follow by the routine named OTHER. To this, the routine named OTHER is invoked by a single command JP C,OTHER.

At least 2 conditions remain: using the BREAK key alone or using no control key. CP $3F checks if the BREAK key was used alone and the following command JP Z,BRK will be executed if this condition is true.

The routines BRK, CTRL, and SHIFT are not shown, any coding may follow.


Entrypoint $0021
Function write header info
Symbolic name WRINF
Protected registers all except AF
Description

This subroutine writes the tape header on tape.

The tape header is located at $10F0. All information needed must be written to the tape header prior to the execution of this subroutine. For further information see the structure of the tape header.

The user will be prompted to press the press keys RECORD PLAYRECORD.PLAY button at the data recorder to start the tape if not already done. Then the message "Writing filename" will be shown on the screen.

The carry flag is set on return to the caller if the break condition did occur during the execution of this subroutine ( SHIFT+BRK keys pressed ).

Please take a note of the description of the tape data processing too.

Example:

B000 CD2100   CALL $0021    ;write tape header
B003 DAxxxx   JP   C,BREAK  ;break condition occurred during write
 
10F0 01 20 51 44 52 4F 4D 0D  . QDROM.
10F8 20 20 20 20 20 20 20 20
1100 20 20 00 08 00 E8 AD 00    ....ü.
1108 00 00 00 00 00 00 00 00  ........
1110 00 00 00 00 00 00 00 00  ........
1118 00 00 00 00 00 00 00 00  ........
1120 00 00 00 00 00 00 00 00  ........
1128 00 00 00 00 00 00 00 00  ........
1130 05 01 00 12 43 64 00 00  ....C...
1138 00 00 FF 00 00 06 00 00  ........
1140 00 06 01 00 05 00 00 EA  ........
1148 10 00 00 00 00 00 00 00  ........
1150 00 00 00 00 00 00 00 00  ........
1158 00 00 00 00 00 00 00 00  ........
1160 00 00 00 00 00 00 00 00  ........
1168 00 00 00 00 00 00 00 00  ........

The complete information must be stored into the tape header before invoking the routine by CALL $0021. You'll find the information needed to construct the tape header here. To write the data of a file to tape see the next subroutine $0024.


Entrypoint $0024
Function write data
Symbolic name WRDAT
Protected registers all except AF
Description

This subroutine stores the data to be saved on the tape.

The carry flag is set on return to the caller if the break condition did occur while executing this subroutine.

Please take a note of the description of the tape data processing too.

Example:

B000 CD2100   CALL $0021    ;write tape header
B003 DAxxxx   JP   C,BREAK  ;break condition occurred during write
B006 CD2400   CALL $0024    ;write file data to tape
B009 DAxxxx   JP   C,BREAK  ;break condition occurred during write
B00C C3AD00   JP   $00AD    ;goback to monitor

Note, the tape header must be written to tape before writing a file by CALL $0024. To this, see the subroutine $0021.


Entrypoint $0027
Function read header info
Symbolic name RDINF
Protected registers all except AF
Description

This subroutine reads the next tape header found on tape and copies it to the memory beginning at $10F0.

Click on the following link for further details about the structure of the tape header.

The user will be prompted to press the press key PLAYPLAY button at the data recorder to start the tape if necessary.

The following conditions can occur on the return to the caller:

Contents of the
accumulator
register A
Contents
of the
carry flag
Meaning
$00 0 normal end of process
$01 1 read error on tape occurred
$02 1 break condition

Please take a note of the description of the tape data processing too.

Example:

B000 CD2700   CALL $0027     ;read tape header
B003 B7       OR   A         ;set flags
B004 CAxxxx   JP   Z,OK      ;header read without any problem
B007 3D       DEC  A         ;A = A - 1
B008 CAxxxx   JP   Z,RDERROR ;A = 1 means error during read 
B00B C3xxxx   JP   BREAK     ;break condition occurred during read

Read the tape header prior to the data to get the information needed about the file ( e.g. length of the file, target location in the storage ).


Entrypoint $002A
Function read data
Symbolic name RDDAT
Protected registers all except AF
Description

This subroutine reads the next data file of a tape.

The file will be stored to the storage location as defined by the tape header. To this, see the structure of the tape header.

The possible conditions on return to the caller are the same as previously defined at the subroutine $0027. The tape header should be read prior to the execution of this subroutine.

Please take a note of the description of the tape data processing too.

Example:

B000 CD2A00   CALL $002A     ;read file
B003 B7       OR   A         ;set flags
B004 CAxxxx   JP   Z,OK      ;no error, no break
B007 3D       DEC  A         ;A = A - 1
B008 CAxxxx   JP   Z,RDERROR ;A = 1 means error during read 
B00B C3xxxx   JP   BREAK     ;break condition occurred during read

Read the tape header prior to the data to get the information needed about the file ( e.g. length of the file, target location in the storage ).


Entrypoint $002D
Function verify
Symbolic name VERFY
Protected registers all except AF
Description

This subroutine verifies the data stored on tape and must immediately subfollow a save process.

The possible conditions on return to the caller are the same as previously defined at the subroutine $0027.

Please take a note of the description of the tape data processing too.

Example:

B000 CD2D00   CALL $002D     ;read file
B003 B7       OR   A         ;set flags
B004 CAxxxx   JP   Z,OK      ;no error, no break
B007 3D       DEC  A         ;A = A - 1
B008 CAxxxx   JP   Z,RDERROR ;A = 1 means verify error
B00B C3xxxx   JP   BREAK     ;break condition occurred during read

If a verify error occurs the file must be resaved.


Entrypoint $0030
Function play melody
Symbolic name MELDY
Protected registers all except AF
Description

This subroutine plays a melody defined by a character string pointed to by DE.

The character string must be defined like the definitions of the BASIC command MUSIC and must be terminated by $0D or $C8.

On return to the caller the carry flag is set to 0 normally. If the execution of the melody subroutine is terminated by BREAK then the carry flag is set at return to caller.

See the subroutine $0041 to play the melody by a specified tempo.

Valid notes are C, D, E, F, G, A, B, and additional a preceding # to play a seminote is valid, for example, #C, #D, #F, #G, and #A.

Code R to rest between notes. A numeric suffix from 0 to 9 is valid and specifies the time of the note / rest to be played. See the following table:

Suffix
value
Meaning
0
1 / 32 note
1
1 / 16 note
2
Dotted 1 / 16 note
3
1 / 8 note
4
Dotted 1 / 8 note
5
1 / 4 note
6
Dotted 1 / 4 note
7
1 / 2 note
8
Dotted 1 / 2 note
9
Whole note

A preceding - or + specifies the octave. Code - for the lower octave and + for the upper octave. Nothing specified plays the normal / middle octave. $CF specifies the lower octave too. $D7 specifies the upper octave too.

The volume can be controlled only by the volume control ( potentiometer ) at the reverse side of the MZ-700.

Try this example:

B000 1150B0 LD   DE,$B050 ;address to string to be played
B003 CD3000 CALL $0030    ;execute music play
B006 C3AD00 JP   $00AD    ;return to monitor

and set the area starting from $B050 to the following values by the "M"-command:

B050 2B 41 33 2B 23 46 31 2B  +A3+#F1+
B058 41 2B 42 33 41 2B 44 2B  A+B3A+D+
B060 23 46 31 41 2B 44 33 41  #F1A+D3A
B068 2B 44 2B 23 46 31 41 2B  +D+#F1A+
B070 44 33 2B 23 46 31 41 2B  D3+#F1A+
B078 44 2B 45 2B 23 46 2B 47  D+E+#F+G
B080 2B 41 33 52 0D           +A3R.

Now execute the jump command JB000 and Beethoven's sonata D major ( opus 25 ) should be played, sure, not at all :-) The tempo can be set by $0041.

Please refer to the description of the 8253 too ( how to play a melody ).


Entrypoint $0033
Function set time
Symbolic name TIMST
Protected registers all except AF
Description

This subroutine sets and starts the internal clock.

On entrance the register DE must contain the time in seconds. The maximum value accepted is $A8C0 or 43,200 seconds ( 12 hours ).

To indicate AM or PM set the accumulator register to a value shown by the following table:

Contents of the
accumulator
register A
Meaning
$00 AM
$01 PM

Please take a note of the description of the internal clock too.

Example:

To set the time to 05:32:12 PM you have to compute this time in seconds.

First set the accumulator to the PM value of $01.

Compute the hours: 5 x 60 minutes x 60 seconds result into 18,000 seconds. Now you have to compute the minutes. There are 32 minutes x 60 seconds per minute result into 1,920 seconds. Add the remaining 12 seconds and the other two values: 18,000 + 1,920 +12 = 19,932 seconds. At last compute this decimal value into a hex value ( $4DDC ) and load DE with this value:

B000 3E01   LD   A,$01    ;PM value to the accu
B002 11DC4D LD   DE,$4DDC ;time value to DE (05:32:12)
B005 CD3300 CALL $0033    ;invoke time set subroutine
B008 C3AD00 JP   $00AD    ;goback to monitor 

The clock is set now and works. If you have to convert other values use my calculator written in Java ( activate JavaScript and Java applets of your browser ).


Entrypoint $0038
Function interrupt routine
Symbolic name none
Protected registers all
Description

This subroutine invokes the interrupt routine as pointed to by the location $1038.

During the startup of the monitor this storage location was initiated with $C38D03. The translated mnemonic to this is: JMP $038D. The subroutine starting at $038D toggles the AM / PM value for the internal clock and reinitiates the clock to 12:00h. The toggled AM / PM-value is located at $119B.

Changing the address of the jump command at location $1038 enables you to write your own interrupt routine located anywhere in the memory. Set the timer to any value needed.

For example, you can write a program that will take effect to any self programmed function key F1 - F10.

To this, the timer must be set to an acceptable value. This means, if you store a low value into the timer the function key will be processed quick but then there may be a high rate of interrupts and by this your system processing time slows down.

If the rate of interrupts is reduced by a higher timer value then it may be the time a function key will be noticed is too slow. Tuning must be done to get an acceptable timer value between system processing time and the time when a function key stroke will be noticed. May be some time critical subroutines ( e.g. write / read tape and so on ) may not function correct.

Please take a note of the description of the time interrupt too.


Entrypoint $003B
Function read time
Symbolic name TIMRD
Protected registers all except AF and DE
Description

This subroutine reads the internal clock.

On exit the register DE contains the time in seconds. The maximum value returned can be $A8C0 or 43,200 seconds ( 12 hours ).

The monitor subroutine indicates AM or PM by the accumulator register A and to this it contains one of the values shown by the following table:

Contents of the
accumulator
register A
Meaning
$00 AM
$01 PM

Please take a note of the description of the internal clock too.

Example:

The returned value contained in the register DE must be computed from seconds into hours, minutes, and seconds. To this you can use my calculator written in Java ( activate JavaScript and Java applets of your browser ).

You can download an example ( 7KB ) that displays the current time. The clock counts from 00:00:00 to 23:59:59.

The ZIP-file to download contains the source code for this routine, an assembler output listing, and an executable MZF-formatted file.

The source is completely documented by my comments for each instruction sequence.

The clock will not be set by my program. Maybe, you'll program an input routine that prompts the user for the time to be set and that computes the time to seconds before setting the time by a CALL $0033. ;) Then combine both programs and... don't forget to post me your result ;-)


Entrypoint $003E
Function activate bell
Symbolic name BELL
Protected registers all except AF
Description

Performing this subroutine a beep tone ( upper octave note A 1 / 32 note = +A0, 880 Hz ) will come over the loudspeaker.

Please take a note of the description of the sound functions too.

Example:

B000 CD3E00   CALL $003E ;beep
B003 C3AD00   JP   $00AD ;goback to monitor 

No more instructions were needed.


Entrypoint $0041
Function set tempo
Symbolic name XTEMP
Protected registers all except AF
Description

This subroutine sets the tempo ( speed ) to play music by the subroutine $0030.

The accumulator register must be established by the appropriate value:

Contents of the
accumulator
register A
Meaning
$01 slow ( Lento, Adagio )
$04 medium ( Moderato )
$07 quick ( Molto Allegro, Presto )

Please take a note of the description of the sound functions too.

Example:

B000 3E07     LD   A,$07    ;presto
B002 CD4100   CALL $0041    ;set tempo
B005 1150B0   LD   DE,$B050 ;address to string to be played
B008 CD3000   CALL $0030    ;play melody
B00B C3AD00   JP   $00AD    ;goback to monitor
 
B050 2B 41 33 2B 23 46 31 2B  +A3+#F1+
B058 41 2B 42 33 41 2B 44 2B  A+B3A+D+
B060 23 46 31 41 2B 44 33 41  #F1A+D3A
B068 2B 44 2B 23 46 31 41 2B  +D+#F1A+
B070 44 33 2B 23 46 31 41 2B  D3+#F1A+
B078 44 2B 45 2B 23 46 2B 47  D+E+#F+G
B080 2B 41 33 52 0D           +A3R. 

Please take a kindly note of the description of the subroutine $0030 too.


Entrypoint $0044
Function start a continuous audible tone
Symbolic name MSTA
Protected registers BC and DE
Description

This subroutine starts a continuos tone which is audible by the loudspeaker.

The frequency of the tone is computed by:

f = 1108.8 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.

The value of 1108.8 kHz = 1.1088 MHz ( kilo-Hertz, kilocycles; Mega-Hertz, Mega cycles ) can vary by your MZ-700. I measured a value of 1.108372 MHz of my MZ-731 with a frequency counter.

Note, your 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.

Please take a note of the description of the sound functions too.

Example:

A continuos tone of 100 Hz is to invoke. For computations and conversions use my calculator written in Java ( activate JavaScript and Java applets of your browser ).

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.

B000 21502B   LD   HL,$2B50   ;load counter value
B003 22A111   LD   ($11A1),HL ;into memory
B006 CD4400   CALL $0044      ;start tone of 100 Hz
B009 C3AD00   JP   $00AD      ;goback to monitor

At this point a tone of 100 Hz is audible. To stop the tone use the subroutine $0047.


Entrypoint $0047
Function stop audible tone
Symbolic name MSTP
Protected registers all except AF
Description

This subroutine stops the tone started by $0044.

Please take a note of the description of the sound functions too.

Example:

B000 CD4700   CALL $0047 ;stop the tone
B003 C3AD00   JP   $00AD ;goback to monitor

At this point no tone is audible.


Entrypoint $004A
Function start the monitor
Symbolic name START
Protected registers none
Description

This is the entrypoint of the monitor.

Transferring control to this location takes the same effect like executing the subroutine $0000. See the description of the subroutine $0000.


Entrypoint $00AD
Function warm start of the monitor
Symbolic name ST1
Protected registers none
Description

This is the warm start address of the monitor.

If your own subroutine terminates and transfers back the control to the monitor by a assembler JP $00AD command then you should set the stack pointer to $10F0 prior to the termination of your subroutine.

Example:

C530 31F010  LD   SP,$10F0 ;set up stack pointer
C533 c3AD00  JP   $00AD    ;goback to monitor

The stack pointer is set to the top of its stack and then the control is transferred to the warm start entry of the monitor.


Entrypoint $018F
Function plot character
Symbolic name LPRNT
Protected registers DE and HL
Description

This subroutine plots the ASCII-character contained in the accumulator register A.

.Example:

B000 3E41     LD   A,$41 ;char "A" to accu
B002 CD8F01   CALL $018F ;plot char
B005 C3AD00   JP   $00AD ;goback to monitor

The letter "A" is loaded into the accu A and then plotted by $018F.


Entrypoint $01A5
Function plot character string
Symbolic name PMSG
Protected registers all
Description

This subroutine plots an ASCII character string which is stored in the memory.

The register DE must point to the string on entry to $01A5.

The character string must be terminated by $0D.

Example:

B000 1124C1     LD   DE,$C124 ;address to char string
B002 CDA501     CALL $01A5    ;plot char string
B005 C3AD00     JP   $00AD    ;goback to monitor
 
C124 41 42 43 44 0D xx xx xx  ABCD.....

The address of the string ABCD is $C124 and loaded into DE. Then the string is plotted by $01A5.


Entrypoint $01C7
Function play melody
Symbolic name ?MELDY
Protected registers all except AF
Description

This subroutine is referenced by the vector $0030. Please follow the previous link for a detailed description.


Entrypoint $02A6
Function DE = DE + 4
Symbolic name .4DE
Protected registers all except DE
Description

This subroutine increments the register DE 4 times.

Example:

B000 CDA602   CALL $02A6 ;adds 4 to DE

No more instructions were needed. On return from $02A6 the register DE is incremented four times, that means DE = DE + 4.


Entrypoint $02AB
Function start the melody
Symbolic name MLDST
Protected registers BC and DE
Description

This subprogram is referenced by the vector MSTA at $0044. Please follow the previous link for a detailed description.

Please take a note of the description of the sound functions too.


Entrypoint $02BE
Function stop the melody
Symbolic name MLDSP
Protected registers all except AF
Description

This subprogram is referenced by the vector MSTP at $0047. Please follow the previous link for a detailed description.

Please take a note of the description of the sound functions too.


Entrypoint $02C8
Function controls tempo and time periods
Symbolic name RYTHM
Protected registers C ( B is used ), DE
Description

RYTHM is used to control the tempo a melody is to be played and to control the time periods for a note / rest.

This routine is used by the routine MELDY / ?MLDY which plays a melody. Follow one or both of the previous links for a detailed description.

Please take a note of the description of the sound functions too.


Entrypoint $02E5
Function set tempo
Symbolic name ?TEMP
Protected registers all except AF
Description

?TEMP sets the tempo of a melody to be played.

This subprogram is referenced by the vector $0041 and is described in detail there.

Please take a note of the description of the sound functions too.


Entrypoint $030B
Function set time
Symbolic name ?TMST
Protected registers all except AF
Description

?TMST sets the time.

This subprogram is referenced by the vector $0033 and is described in detail there.

Please take a note of the description of the internal clock too.


Entrypoint $0352
Function bell data
Symbolic name ?BELD
Protected registers No machine instruction code.
Description

This is a data area used by the BELL subroutine.

0352 D7 41 30 0D xx xx xx xx  .A0.....

$D7 defines the upper octave for the note A ( $41 ) and the note A will be played by a rest of 0 ( $30 ).

See the description of the BELL routine for more details.


Entrypoint $0358
Function read time
Symbolic name ?TMRD
Protected registers all except AF, DE
Description

?TMRD reads the internal clock.

This subprogram is referenced by the vector $003B and is described in detail there.

Please take a note of the description of the internal clock too.


Entrypoint $038D
Function time interrupt routine
Symbolic name TIMIN
Protected registers all
Description

This subroutine invokes the interrupt routine as defined at the location $1038. See the description of $0038 for more details.

Please take a note of the complete description of the time interrupt too.


Entrypoint $03B1
Function display space and a byte converted into 2 display characters.
Symbolic name SPHEX
Protected registers all except AF
Description

This subroutine prints a space at the current cursor position. Additional one byte pointed to by HL will be converted into its 2-digits hexadecimal display codes which are then displayed on the screen.

This means, the upper four bits of the byte will be converted first into a display character in the range from 0 to 9 ( display code $20 - $29 ) and from A to F ( display code $01 - $06 ). The result is put into the video RAM at the current cursor location and by this it becomes visible. Next the lower four bits are converted and displayed next ( same ranges, of course ).

You can use this routine to display any byte from the memory in hexadecimal notation separated by a single space character.

Example:

B000 2135A0   LD   HL,$A035 ;points to char
B003 CDB103   CALL $03B1    ;print space & char in hex
B006 C3AD00   JP   $00AD    ;goback to monitor

A035 A1 xx xx xx xx xx xx  a.......

First, a space will be printed at the current cursor position. Next, the byte at location $A035 will be displayed on the screen in display code notation and split into 2 display codes, i.e. "A1" is displayed. The display code is $01 $21 which is put into the character part of the video RAM at the current cursor position becomes visible as "A1" preceded by a single space.


Entrypoint $03BA
Function display contents of the register HL in a 4-digits hex notation.
Symbolic name PRTHL
Protected registers all except AF
Description

This subroutine displays the contents of HL in a 4-digit hexadecimal notation.

To this the upper 4 bits of register H are converted into a displayable hexadecimal digit in the range from 0 to 9 ( display code $20 - $29 ) or A to F ( display code $01 - $06 ). It will be put into the character video RAM at the current cursor position and by this it becomes visible.

Next, the lower four bits of register H will be converted and displayed by the same procedure as described.

At last the contents of the register L will be displayed by the same procedure as used for the register H.

On exit of this subroutine 4 characters in hexadecimal notation are displayed on the screen which represent the contents of the register HL in hexadecimal notation. The high order half of the register HL, this is the register H, is displayed first and next the register L.

You can use this routine to display the contents of the register HL in hexadecimal notation. To get the contents of another register or if you want to display an address located in the memories load it into the register HL before executing this subroutine.

Example:

B000 2A35A0   LD   HL,($A035) ;load memory contents of $A035
B003 CDB103   CALL $03BA      ;print "35A1"
B006 C3AD00   JP   $00AD      ;goback to monitor

A035 A1 35 xx xx xx xx xx  a!......

Two bytes from the location $A035 are split into 4 display codes The display code is $23 $25 $01 $21 which is put into the video RAM at the current cursor position and by this it becomes visible as 35A1.


Entrypoint $03C3
Function display contents of the accumulator register A in 2-digits hex notation..
Symbolic name PRTHX
Protected registers all except AF
Description

The contents of the register A will be converted into its 2-digits hexadecimal display codes which are displayed on the screen.

This means, the upper four bits of register A will be converted first and the result of the conversion is a display character in the range from 0 to 9 ( display code $20 - $29 ) and from A to F ( display code $01 - $06 ) which will be displayed. Next the lower four bits are converted and displayed ( same ranges, of course ).

You can use this subroutine to display the contents of the accumulator register A in hexadecimal notation.

You can use this subroutine too to display the contents of any byte located in the memory if you load it into the accumulator register A prior to the execution of this subroutine.

If you load another register half into the accumulator register A it will be displayed too as described above.

Example:

B000 7B     LD   A,E   ;load register E into accumulator A
B001 CDB103 CALL $03C3 ;print contents of accu (same as register E)
B004 C3AD00 JP   $00AD ;goback to monitor

The contents of register E is to display in 2-digits hexadecimal notation. To this, first the contents of the register E is loaded into the accumulator register A ( $B000 ). The contents of the accumulator register A is split into 2 display codes. The display codes will be put into the character part of the video RAM at the current cursor position and by this it becomes visible ( all done by the CALL $03B1 at $B001 ).


Entrypoint $03DA
Function display contents of the 4 lower bits of the accumulator register A in hex notation.
Symbolic name ASC
Protected registers all except AF
Description

This subroutine converts the four lower bits of the accumulator register A into its associated ASCII character.

The accumulator register contains this value on return to the caller.

Example:

B000 3E0E     LD   A,$0E ;load char to convert
B002 CDDA03   CALL $03DA ;convert $0E to $45
B005 CD1200   CALL $0012 ;print ASCII "E" ($45)
B008 C3AD00   JP   $00AD ;goback to monitor

The four lower bits of the accu ( 1110 of 0000 1110 ) are converted to the ASCII-character $45 by the CALL $003DA and stored back into the accu. By this the upper four bits of the accu are lost. The following CALL $0012 will print the contents of the accu as "E" at the current cursor position.


Entrypoint $03F9
Function puts the ASCII hex value contained in the accu into the 4 lower bits of the accumulator register.
Symbolic name HEX
Protected registers all except AF
Description

This subroutine converts an ASCII hexadecimal number contained in the accu A into a 4-digit binary value. The result of the conversion is stored back into the four lower bits of the accu A. The four upper bits of the accu A are set to zero.

If the accu A contains a non-hex character on entry to $03F9 the carry flag is set. In this case no conversion can be done and the returned value of the accu A is invalid.

Example:

B000 3E45     LD   A,$45   ;load char to convert
B002 CDF903   CALL $03F9   ;convert $45 to $0E
B005 DAxxxx   JP   C,NOHEX ;no hex char in accu
B008 CDC303   CALL $03C3   ;print ASCII $30 $45 (ASCII 0E)
B00B C3AD00   JP   $00AD   ;goback to monitor

The ASCII-character $45 is converted into $E by the CALL $003F9 and stored back into the four lower bits of the accu A. The upper four bits of the accu are set to zero. The following CALL $03C3 will print the contents of the accu as "0E" at the current cursor position.


Entrypoint $0410
Function puts an 4-digits ASCII hex value into HL.
Symbolic name HLHEX
Protected registers BC, DE
Description

This subroutine stores 4 ASCII characters representing 4 hex digits into HL.

On entry to this subroutine the register DE must point to the memory location of the 4 ASCII characters. Valid ASCII characters are 0 - 9 ( $30 - $39 ), and A - F ( $41 - $46 ), otherwise the carry flag will be set on return to the caller.

Example:

B000 1120B0   LD   DE,$B020 ;load address of string
B003 CD1004   CALL $0410    ;convert $41314539 to $A1E9
                            ;and store to HL
B006 DAxxxx   JP   C,NOHEX  ;invalid char found in string
B009 C3AD00   JP   $00AD    ;goback to monitor

 
B020 41 31 45 39 xx xx xx xx  A1E9....

The ASCII string pointed to by DE will be converted into a 4-digits hex value and this 16 bits binary value will be stored into HL. The first 2 ASCII characters are converted and stored into H, the last 2 ASCII characters are converted and stored into L.


Entrypoint $041F
Function puts an 2-digits ASCII hex value into the accu A.
Symbolic name 2HEX
Protected registers all except AF
Description

This subroutine stores two ASCII characters representing two hex digits into the accu A.

On entry to this subroutine the register DE must point to the memory location of the two ASCII characters. Valid ASCII characters are 0 - 9 ( $30 - $39 ), and A - F ( $41 - $46 ), otherwise the carry flag will be set on return to the caller.

Example:

B000 1120B0   LD   DE,$B020 ;load address of string
B003 CD1F04   CALL $041F    ;convert $4131 to $A1
                            ;and store to accu
B006 DAxxxx   JP   C,NOHEX  ;invalid char found in string
B009 C3AD00   JP   $00AD    ;goback to monitor

 
B020 41 31 xx xx xx xx xx xx  A1......

The ASCII string pointed to by DE will be converted into a 2-digits hex value and this 8 bits binary value will be stored into the accu A. The first ASCII character is converted and stored into the upper 4 bits, the last ASCII character is converted and stored into the lower 4 bits.


Entrypoint $0577
Function activate bell.
Symbolic name ?BEL
Protected registers all except AF
Description

A beep tone ( upper octave note A 1 / 32 note = +A0, 880 Hz ) will come over the loudspeaker performing this subroutine.

This subroutine is referenced by the vector $003E. Click on the previous link for more information.

Please take a note of the description of the sound functions too.


Entrypoint $09B3
Function waits until a key is pressed.
Symbolic name ??KEY
Protected registers all except AF
Description

This subroutine waits until any key is pressed.

On return to caller the accumulator register contains the display code of the key pressed. To see the display code for the control keys click here.

Example:

B000 CDB309   CALL $09B3 ;wait on key

B003 CD4A09   CALL $094A ;print
B006 C300B0   JP   $B000 ;loop until reset

CALL $09B§ waits on a key input and the next CALL to $094A will print its associated value at the current cursor position. Note, this example loops until hard reset.


Entrypoint $0BB9
Function ASCII code to display code conversion.
Symbolic name ?ADCN
Protected registers all except AF
Description

This subroutine translates the MZ-700 ASCII code to the display code.

Put the ASCII code into the accumulator register and call this subroutine. On return to the caller the accumulator register contains the display code, but it will not be displayed by this.

Example:

B000 3E45     LD   A,$45 ;load ASCII "E" 
B002 CDB90B   CALL $0BB9 ;convert to display code $05
B005 CD4A09   CALL $094A ;print
B008 C3AD00   JP   $00AD ;goback to monitor

The ASCII character "E" will be converted into its display code $01 by the instruction sequence $B000 - B002. The next CALL $094A will display it on screen.


Entrypoint $0BCE
Function ASCII code to display code conversion.
Symbolic name ?DACN
Protected registers all except AF
Description

This subroutine translates the display code to the MZ-700 ASCII code

Put the display code into the accumulator register and call this subroutine. On return to the caller the accumulator register contains the ASCII code, but it will not be displayed by this.

Example:

B000 3E01     LD   A,$01 ;load display code $01 
B002 CDCE0B   CALL $0BCE ;convert to ASCII code $41
B005 CD1200   CALL $0012 ;print
B008 C3AD00   JP   $00AD ;goback to monitor

The display code $01 will be converted into its ASCII code $41 ( character "A" ) by the instruction sequence $B000 - B002. The next CALL $094A will display it on screen.


Entrypoint $0DA6
Function wait on VBLK
Symbolic name ?BLNK
Protected registers all
Description

This subroutine waits on the start of a vertical blanking signal ( VBLK ). This will be when writing of a new line of the screen begins.

This subroutine may be useful for programming an application using joysticks.

Example:

B000 CDA60D   CALL $0DA6 ;wait on VBLK

On return to the caller the signal VBLK is active.


Entrypoint $0DDC
Function screen control
Symbolic name ?DPCT
Protected registers all
Description

Load the following value into the accumulator register prior to the call of this subroutine and the screen will be controlled by the control characters as defined in the following table:

Contents of the
accumulator
register A
Function
$C0 scroll up
scroll up
$C1 scroll up
scroll up
$C2 scroll down
scroll down
$C3 cursor right
scroll right
$C4 cursor left
scroll left
$C5 home
Home position
$C6 clear
Clear screen
$C7 DEL
$C8 INST
$C9 ALPHA
$CA GRAPH
$CD CR

Example:

B000 3EC6     LD   A,$C6 ;load char for clear
B002 CDDC0D   CALL $0DDC ;clear screen
B005 C3AD00   JP   $00AD ;goback to monitor

The screen will be cleared while processing the control character $C6 by $0DDC.


Entrypoint $0FB1
Function puts address of cursor position into HL
Symbolic name ?PONT
Protected registers BC, DE
Description

On return to the caller the register HL contains the address of the current cursor position in the character RAM starting at location $D000.

You can add $800 to HL to get the current color information byte associated to this character.

Example:

B000 CDB10F    CALL $0FB1 ;get address of cursor in char VRAM
B003      ; address of cursor now available in register HL.
          ; you can set bit 3 of register H to point to color VRAM
          ; by SET 3,H  and back by RES 3,H 

No more instructions were needed.


Go to the top of this page Home

last updated February 2, 2010
sharpmz@sharpmz.org