ROM BIOS

The design of the SV ROM is of importance if machine code programs are to be developed efficiently and Operate reliably. Almost every program, including the BASIC Interpreter itself, will require a certain set of primitive functions to operate. These include screen and printer drivers, a keyboard decoder
and other hardware related functions. By separating these routines from the BASIC Interpreter they can be made available to any application program. The section of ROM from 0000H to 0180H is largely devoted to such routines and is called the ROM BIOS (Basic Input Output System).

This page gives a functional description of routines in the ROM BIOS. Special attention is given to the "standard" routines. The first few hundred bytes of the ROM consists of Z80 JP instructions which provide fixed position entry points to these routines. For maximum compatibility with future software an application program should restrict its dependence on the ROM to these locations only. The description of the ROM begins with this list of entry points to the standard routines. A brief comment is placed with each entry point, the full description is given with the routine itself.
 

Data Areas

It is expected that most users will wish to disassemble the ROM to some extent (the full listing runs to nearly four hundred pages). In order to ease this process the data areas, which do not contain executable Z80 code, will be added later.
 

Terminology

Reference is frequently made in this chapter to the standard routines and to Workspace Area variables. Whenever this is done the Microsoft-recommended name is used in upper case letters, for example "the FILVRM standard routine" and "SCRMOD is set". When reference is made to the Z80 status flags assembly language conventions are used, for example "Flag C" would mean that the carry flag is set while "Flag NZ" means that the zero flag is reset. The terms "EI" and "DI" mean enabled interrupts and disabled interrupts respectively.
 

Address Name Description
0008 SYNCHK Looks at the current (HL) character to check if it equals the character after SYNCHK call, otherwise "Syntax Error"
0010 CHRGET Incr HL, get character into A and set flags: C=numeric, Z=EOL (":" or 0)
0018 OUTDO Output a character in A using PRTFLG, TTYPOS, etc.
0020 COMPAR Compares HL and DE : HL>DE sets C, HL=DE sets Z
0028 SIGN Returns A=-1 if FAC<0, 0 if FAC=0, 1 if >0, works on single and double precision constants.
0030 GETYPR Get valtyp and set condition codes (flags). INT=2 (SIGN), STR=3 (Z), SNG=4 (ODD P), DBL=8 (NC)
0038 KEYINT Interrupt handler
003B CHSNS Sense keyboard buffer for character, sets Z if no key
003E CHGET Get character from keyboard buffer (waits), returns key in A
0041 CHPSTT Line printer status test, Z if not ready
0044 CHPLPT Line printer character output, A contains the character
0047 INITXT Initialize VDP to 40x24 Text Mode (screen 0)
004A INIGRP Initialize VDP to Graphics Mode (screen 1)
004D INIMLT Initialize VDP to Multicolor Mode (screen 2)
0050 FNKSB Check if function key display on (CNSDFG), and shows them if it's on.
0053 ERAFNK Erase function key display
0056 DSPFNK Display function keys
0059 RSTFNK Initialize function key strings
005C BREAKX Check CTRL-STOP key directly, C if pressed
005F JMPBNK Jump to memory bank
0062 CALBNK Call on a subroutine in another memory bank
0066 NMI Non Maskable Interrupt handler
0069 CSRDON Cassette motor on and wait for Sync and Header
006C CASIN Read data byte for byte from the cassette to A
006F CTOFF Cassette motor off
0072 CWRTON Cassette motor on and write Sync and Header
0075 CASOUT Write data byte for byte from A to the cassette
0078 CTWOFF Write 0 to the cassette and turn motor off
007B CRDO Put CR to output device
007E CRDONZ Put CR to output device if not at left position
0081 OUTDLP Put char in A to Lpt and decode TAB, CR and skip rest of the Ctrl-characters
0084 STRINI  
0087 PUTNEW  
008A FRESTR  
008D STROUT  
0090 READYR Reset stack when Basic externally stopped and then restart
0093 SNERR Print "Syntax Error"
0096 ERROR Print error number in E
0099 NTDERR  
009C READY Warmstart
009F LINKER Goes through the program and fixes links
00A2 NEWSTT New statement fetcher
00A5 FCERR Function call error
00A8 FINLPT Reset output device to video and move Lpt head to left margin
00AB EVAL Evaluate variable, constant, function call. Put result in FAC
00AE FRMEVL Formula evaluation routine
00B1 GETBYT  
00B4 FRMQNT Get integer value from formula
00B7 CONINT Convert FAC to an integer in DE
00BA SNGFLT  
00BD GETIN2  
00C0 CRUNCH Translates all reserved words into tokens
00C3 CHEAD Goes through program and fixes links from position in DE
00C6 CONIA Convert signed number in A to integer
00C9 INEG2 Convert integer into single precision, put in FAC
00CC MAKINT Put HL in FACLO, set valtyp to integer
00CF DIOERR  
00D2 POPALL  
00D5 EOF Close file with # in FAC
00D8 POPHRT  
00DB LINPRT  
00DE OMERR Fixes program links, resets SAVSTK and prints "Out of memory"
00E1 RUNC Initiates for RUN
00E4 NAMSCN Scan filename and device
00E7 SCNBLK Scan block
00EA GETFLP Get pointer to file with number in FAC
00ED GETPTR Same as above but number in A
00F0 SETFIL Test if file with # in A is open and returns pointer
00F3 NULOPN Open file: Drive in D, mode in E (4=filemode no "FOR", 1="INPUT", 2="OUTPUT", 8="APPEND"), file# in A
00F6 CLSFIL Close file# in A
00F7 NOCLSB  
00FC CLSALL Close all files if NLONLY<>0
00FF FILOU1 Writes a character in A into disc
0102 INDSKC Gets a character from disk into A. Carry if EOF
0105 CLRBUF Clears data buffer of selected file. On return HL points at start of buffer
0108 DOCLR Clear B # of bytes starting at HL
010B NOSKCR  
010E DERBFN "BAD FILE NAME"
0111 DERFAO "FILE ALREADY OPEN"
0114 DERFNF "FILE NOT FOUND"
0117 DERFNO "FILE NOT OPEN"
011A DERIER "INTERNAL ERROR"
011D DERRPE "READ PAST EOF"
0120 MAKUPL  
0123 CRN2ND  
0126 PUTBNK  
0129 GETBNK  
012C GETDEV Returns device # in A from PTRFIL (F997H)
012F NOROOM No room for program loaded from disk: Erase, Close files and print "OUT OF MEMORY"
0132 CHKTOP Check if enough room, else fall into NOROOM
0135 GETBF11  
0138 DERFOV "FIELD OVERFLOW"
013B NAMSC1  
013E DERSAP  
0141 FILSCN  
0144 GETBUF  
0147 BEEP  
014A CNVCDO  
014D GETLEN  
0150 GETTRM  
0153 GETCOD  
0156 SETTRM  
0159 TERMIN  
015C FINPRT  
015F GTBYTC  
0162 INTIDX  
0165 INILIN  
0168 FRCSTR  
016B GETSPA  
016E CKCNTC  
0171 SCRTCH New command
0174 FRCINT  
0177 INDSKE  
017A PTRGET Get pointer to variable in HL, returns DE as start and HL as end pointer. DE=0 if no variable found
017D SPSVEX  

 

Workspace Area

The section of the Workspace Area from F500H to FE78H holds the BIOS/Interpreter variables. These are listed on the following form:
B = Byte, W = Word, I = Instruction
 

 

Address Type Name Description
F500   RAMLOW  
F504   RNDCNT  
F506   RNDTAB  
F52B   USRTAB USR 0, These ten variables contain the "USR" function addresses. Their values are set to the Interpreter "Illegal function call" error generator at power-up and thereafter only altered by the "DEFUSR" statement.
F52D W USRTAB USR 1
F52F W USRTAB USR 2
F531 W USRTAB USR 3
F533 W USRTAB USR 4
F535 W USRTAB USR 5
F537 W USRTAB USR 6
F539 W USRTAB USR 7
F53B W USRTAB USR 8
F53D W USRTAB USR 9
F53F B ERRFLG Error number
F540   LPTLST Last Lpt operation 0=LF, 0<>print
F541   LPTPOS Position of Lpt print head
F542   PRTFLG 0=output device CRT, 1=output device LPT
F543   LINLEN Line length (39, 40, 80)
F545 B RUBSW Rubout switch=1 means inside the processing of a rubout (inlin)
F546 W STKTOP Top of stack, start of strigarea, 2:nd parameter in CLEAR statement
F548 W CURLIN Current line #, FFFFH at direct statement in execution
F54A W TXTTAB Start of Basic-program
F54C W VLZADR Adress of character replaced by VAL
F54E B   ":" a colon for restarting input
F54F   KBUF This is the KRUNCH buffer
F68D   BUFMIN  
F68E   BUF Input line buffer
F790 B ENDBUF Make sure overrun stops
F791 B TTYPOS Store terminal position
F792 B DIMFLG  
F792 B VALTYP Type of variable
F798   CONSAV  
F7A2 W MEMSIZ End of string area, start of file-buffer area
F7A4 W TEMPPT Temporary pointer
F7A6   TEMPST  
F7C4 B DSCTMP Character count pointer. Temporary string description
F7C5 W DSCPTR Character count pointer
F7C7 W FRETOP This variable contains the address of the next free location in the String Storage Area. When the area is empty FRETOP is equal to MEMSIZ
F7C9   TEMP3  
F7CB   TEMP8  
F7CD   ENDFOR This variable is used by the "FOR" statement handler to hold the end of statement address during construction of a parameter
block
F7D1   SUBFLG  
F7D2   USFLG  
F7D3   TEMP  
F7D5   PTRFLG  
F7D6 B AUTFLG <>0 means AUTO mode
F7D7 W AUTLIN Intial line for AUTO
F7D9 W AUTINC Increment in AUTO
F7DB W SAVTXT  
F7DD W SAVSTK Stack temporary saved during command execution
F7DF W ERRLIN Line number where last error occurred
F7E1 W DDT Current line for edit & list
F7E3 W ERRTXT Text pointer for use by "RESUME"
F7E5 W ONELIN Current line to go to when error occurs
F7E7 B ONEFLG =1 if executing error trap routine, else 0
F7E8 W TEMP2 Text pointer
F7EA w OLDLIN Old line number (setup by <CTRL>-<C>, STOP or END
F7EC W OLDTXT Old text pointer
F7EE W VARTAB Start of simple variables
F7F0 W ARYTAB Start of array variables
F7F2 W STREND End of array variables
F7F4 W DATPTR Adress-1 of line where read DATA
F7F6
-
F80F
  DEFTBL A to Z. Default valtyp for each letter of the alphabet. Set up by clear and changed by DEFSTR, DEFSNG, DEFDBL, DEFINT and used when a variable isn't followed by !,#,$ or %
F810 W PRMSTK This variable contains the base address of the previous "FN" parameter block on the Z80 stack. It is used during string garbage collection to travel from block to block on the stack
F812 W PRMLEN This variable contains the length of the current "FN" parameter block in PARM1
F814 W PARM1 This buffer contains the local Variables belonging to the "FN" function currently being evaluated
F878   PRMPRV This variable contains the address of the previous "FN" parameter block. It is actually a constant used to ensure that string garbage collection commences with the current parameter block before proceeding to those on the stack
F87A   PRMLN2 This variable contains the length of the "FN" parameter block being constructed in PARM2
F8E0   PRMFLG This variable is used during a Variable search to indicate whether local or global Variables are being examined
F8E1   ARYTA2 This variable is used during a Variable search to hold the termination address of the storage area being examined
F8E3   NOFUNS This variable is normally zero but is set by the "FN" function handler to indicate to the variable search routine that local Variables are present
F8E4   TEMP9 This variable is used for temporary storage by various parts of the Interpreter
F8E6   FUNACT This variable contains the number of currently active "FN" functions
F8E8   VLZDAT  
F8E9   SWMTMP This buffer is used to hold the first operand in a "SWAP" statement
F9F1   TRCFLG Zero means no trace in progress. This variable is normally zero but is set by the "TRON" statement handler to turn on the trace facility

 

Variables for disk

Address Type Name Description
F98C B MAXDRV Highest legal drive number
F98D B MAXFIL Highest legal file number
F98E W FILTAB This variable contains the address of the pointer table for the I/O buffer FCBs
F990   ORVTAB  
F992   NULBUF This variable contains the address of the first byte of the data buffer belonging to I/O buffer 0
F994   CURDRW  
F995   DRWPTR  
F997   PTRFIL Point at file data
F999   FREPLC  
F99B   LSTFRE  
F99D   RUNFLG Non-zero if run after load
F99E   FILNAM This buffer holds a user-specified filename. It is eleven characters long to allow for disc file specs such as "FILENAME.BAS"
F9A7   FILNM2 This buffer holds a filename read from an I/O device for comparison with the contents of FILNAM
F9B0 B LSTTRK Last track accessed by DSKI$/DSKO$
F9B1 B LSTSCT  
F9B2 B NLONLY This variable is normally zero but is set during a program "LOAD". Bit 0 is used to prevent I/O buffer 0 being closed during loading and bit 7 to prevent the user I/O buffers being closed if auto-run is required
F9B3 B SAVFLG Non-zero if saving program
F9B4 W SAVEND This variable is used by the "BSAVE" statement handler to hold the end address of the memory block to be saved.
F9B6   DSKBSY  
F9B7   ERRCNT  
F9B8   ERRCN1  
F9B9   RAWFLG Zero for read after write
F9BA   EBCFLG  
F9BB   SAVEBC  
F9BC   STAT0  
F9BD   STAT1  
F9BE   TSTACK  
F9EF     Buffert for formatted filename

The folloving variables are set at power-up

The folloving variables are NOT set at power-up

Variables for circle drawing

Variables for paint

Variables for PUT/GET



 

Source: Tomas Karlsson

 

 
Webmaster: