2.4 Using BIOS

SYS_WAIT

user defined wait cycle

HL: time in 1/10000s (10000 is 1 second)

SYS_BEEP

play tone using built-in speaker

A: tone index (pitch) C=3, D=4,...G=6, A=1, H(B)=2 (ASCII can be used too)

C:octave (0-...)

B: duration

LD A, 'C' ; "C"

LD B, 32 ; 32/128

LD C, 3 ; fourth octave

CALL BEEP ; beep

RST 20

send null-terminated string via serial line

no parameters

string must follow RST20 instruuction

RST 20

.TEXT "HELLO WORLD"

.DB 00h

SYS_KBD_INIT

send initialization sequence to keyboard

returns

B: error code

1- init OK

2- no response from keyboard

3- cannot change status indicator

4- error reading ID

5- cannont change scan code

6- cannot enable keyboard

SYS_KBD_LED

set/change LED indicator

A: LEDs status

bit 0 - Scroll Lock

bit 1 - Num Lock

bit 2 - Caps Lock

SYS_KBD_WRITE

write settings to keyboard

A: command or data to send

returns

CF: reset if ACK received from keyboard

SYS_KBD_READ

get keyboard data

returns

H: scan code from keyboard

L: MSB is parity flag

C: error code

00 - valid data

01 - communication error

FF - no key pressed

WAIT_FOR_KEY:

CALL SYS_KBD_READ

INC C

JR Z, WAIT_FOR_KEY

LD A, H

CP 0F0 ; key up?

SYS_KBD_BLOCK

keep keyboard transfer blocked, keys will be cached

no parameter

SYS_KBD_CHECK

check if keyboard is connected (sends echo command to keyboard)

returns

CF: reset if OK

SYS_TTY_WRITE

send one byte/char to serial line, no stop bit (needs some CPU time to create stop bit with desired length)

A: byte to send

SYS_TTY_READ

read one byte from serial line

return

L: byte from line

CF: set if error occurs

SYS_TTY_NEXT

read one byte, report timeout if no data

L: byte from line

CF: set if error or timout

; reading file example

TTY_GETFILE:

CALL SYS_TTY_READ ; wait for first byte

RET C ; report error (12T)

TTY_GETFILE1:

LD A, L ; byte to ACC ( 4T)

LD (DE), A ; store byte ( 7T)

INC DE ; move pointer ( 6T)

CALL SYS_TTY_NEXT ; read next byte or report timeout (17T)

JR NC, TTY_GETFILE1; save byte and read next one (12T)

XOR A ; flag: timeout

RET ; no more data on line

; return CF set if error

; return CF reset if timeout

SYS_I2C_START

i2c start condition

no parameters

SYS_I2C_STOP

i2c stop condition

no parameters

SYS_I2C_WRITE

send one byte to device

C: byte to write

CF: acknowledge from device

SYS_I2C_RD_ACK

read one byte from device, send positive acknowledge

return

C: byte from device

SYS_I2C_RD_NACK

read one byte from device, send negative acknowledge (often signalizing last byte)

return

C: byte from device

SYS_SPI_READ

read one byte from SPI device

return

C: byte from device

SYS_SPI_WRITE

write one byte to SPI device

C: byte to send

SYS_SPI_RDWR

read and write one byte

C: byte to send

return

C: byte from device

SYS_RTC_SETDATE

set actual date

D: day

E: month

H: year (last two digits)

L: day of week

values are BCD-coded

SYS_RTC_SETTIME

set time

D: hours

E: minutes

A: seconds

SYS_RTC_GETDATE

get date

return

D: day

E: month

H: year (last two digits)

L: day of week

SYS_RTC_GETTIME

get current time

return

D: hours

E: minutes

A: seconds