80-Bus News

  

May–June 1983 · Volume 2 · Issue 3

Page 32 of 59

The workings of Nascom ROM BASIC Ver 4.7

PAGE 10

******** Now for the exciting bit – The ROM ********

Name

Addr

What the routine does

INIT

E019

Copy the initial work space conditions into the work space RAM at 1000 to 105F.

MSIZE

E036

Output “Memory size” prompt and get response from user. If a number is given jump to TSTMEM otherwise start at the beginning of RAM and test each successive byte until the end of RAM is found. When the end has been found jump to SETTOP.

TSTMEM

E05B

Get supplied address.
If any bad characters output “?SN Error” and re-initialise otherwise try to write a D0H byte into that address. If D9H is not read back then there is no RAM at that address so go to MSIZE to ask again. If D0H is read back then drop through to SETTOP.

SETTOP

E06D

Test for minimum memory requirement and if not enough jump to MSIZE to ask again otherwise save this address as the highest available memory location, allocate 50 bytes for string space and output the sign on message and the number of bytes free. Then drop through to WARMST.

WARMST

E0AE

Clear run-time registers and jump to PRNTOK.

BAKSTK

E356

Look back through stack for FOR or GOSUB blocks and exit with HL pointing to the block.

CHKSTK

E38A

Check for “C” levels of stack space and output “?0M Error” if not enough stack space.

DATSUR
TMERR

E3A7 to
E3BF


I like this section of code because you jump into the routine at one of the entry points, this loads the “E” register with the error number and the “LD BC,nn” opcode (01H) skips all the following “LD E,n” instructions. It is very efficient.

ERROR

E3C1

Output error code for error number in the E register, output the line number if needed and drop through to PRNTOK.

PRNTOK

E3F8

Output “Ok” message and drop through to GETCMD.

GETCMD

E405

Get a direct statement or BASIC line, CRUNCH the text and if it is a direct statement go to EXCUTE to execute it. If it is a BASIC line then move it to the program text area.

SRCHLN

E499

Search for line number in register DE.

NEW

E4B9

Set PROGND to start of program text area to effectively remove program from memory and execute the null program to clear all the other pointers.

RUNSFT

E4C5

Execute program from first statement.

INTVAR

E4C9

Clear out variables and string space an reset DATA pointer.

The workings of Nascom ROM BASIC Ver 4.7

PAGE 11

CLREG

E4DF

Reset stack to top of memory, clear out temporary strings, disable CONTinue and execute program.

PROMPT

E4FC

Output “? ” prompt for INPUT and go to get input line.

CRUNCH

E509

Move text string from HL to BUFFER crunching reserved words into tokens as you go.

ENDBUF

E5B8

Mark the end of BUFFER with three nulls.

GETLIN

E5F2

Get an input line from monitor.

TTYLIN

E607

Get an input line by character and save it in BUFFER.

CPDEHL

E68A

Compare the DE register with the HL register returning flags:–
Z – Registers are equal, C – DE > HL and NC- DE <= HL

CHKSYN

E690

Make sure the next byte in the code string is the same as the byte following the “CALL CHKSYN”. If not – output “?SN Error”.

OUTC

E69B

Output character in the A register to the terminal and output a CRLF if the current terminal width is exceeded. Character is not output if CTLOFG is set.

CLOTST

E6CC

Get an input character and flip CTLOFG if it is control “O”.

LIST

E6DD

LIST BASIC program from start (or specified line number) LINESN lines at a time. It does not take into account that graphics may appear in quotes, DATA or REM statements so the graphic character is treated as a reserved word token and expanded to the complete word.

FOR

E779

Assign the initial value to the index variable and then set up a FOR block on the stack.

RUNCNT

E7F2

Main execution driver loop. This gets the next statement (May be after “:” or on next line) and gives it to EXCUTE.

EXCUTE

E816

Test current statement. If it is a key word then find the address of the routine from WORDTB and call it. If it is a letter then call LET to try to assign a variable. Otherwise generate “?SN Error”.

GETCHR

E836

Get next character in code string and return flags:–
Z – End of statement (“:” or null)
C – Character is a digit otherwise NC.

RESTOR

E846

Restore routine. Set DATA pointer to start of program or to specified line if a line number is given.

TSTBRK

E861

Test for break key. If pressed test for control “S” (pause). If another break pressed then stop execution and output break message.

STOP

E870

STOP routine. Flag “STOP” an join END.

NASCOM ROM BASIC dis-assembled is available in ASM and LST file format.

Page 32 of 59