Useful Rom Subroutines For Assembly Programming - Dick Smith VZ200 Technical Reference Manual

Personal colour computer
Table of Contents

Advertisement

12. USEFUL ROM SUBROUTINES FOR ASSEMBLY PROGRAMMING
A. KEYBOARD SCANNING ROUTINE
The keyboard scanning routine resides at 2EF4 hex. This routine
scans the keyboard once and returns. If a key is pressed, the A
register will contain the code for that key; otherwise this
register will contain zero. Registers AF, BC, DE and HL are all
modified by the routine, so if the contents of these registers
must be preserved they should be pushed onto the stack before
the routine is called. The following example shows how the
routine would be used to wait for the RETURN key to be pressed:
SCAN
CALL 2EF4H
OR A
JR
Z,SCAN
CP 0DH
JR NZ,SCAN
• •
;scan kybd once
;any key pressed?
;back if not
;was it RETN key?
;back if not
;otherwise continue
B. CHARACTER OUTPUT SUBROUTINE
A routine which outputs a single character to the video display
is located at 033A hex. The code for the character to be
displayed must be in the A register, while the character will
be displayed on the screen at the position corresponding to the
current value of the cursor pointer. All registers are
preserved. Here is how the routine would be called to display
the word 'HI', followed by a carriage return:
LD A,'H'
CALL 033AH
LD A,'I'
CALL 033AH
LD A, ODH
CALL 033AH
;load A reg with code
;& display
;same for I
;now load A with CR code
;& update screen
C. MESSAGE OUTPUT SUBROUTINE
A very useful subroutine located at 28A7 hex can display a
string of character codes as a message on the screen. The
string of character codes must end with a zero byte. The HL
register pair must be set to the start of the string before the
subroutine is called. All registers are used by the subroutine.
Here is how it is used:
LD HL,MSG
;load HL with start of strg
CALL 28A7H
;& call print subroutine
MSG
DEFM 'READY'
;main message string
DEFB ODH
;carriage return
DEFB 0
;null byte to terminate
17

Advertisement

Table of Contents
loading

Table of Contents