Sharp logo
Entry points and work area 
( of the S-Basic 1Z013B )  

When the interpreter has loaded at $1200, it executes a boot routine at $7D79 which zeroes the internal clock, stores the current cursor positions at their new addresses, and switches out the ROM Monitor and Video RAM areas. It then loads itself down to commence at $0000, on the way it loses the boot section and after the initial screen message is printed this is wiped out too. Strangely enough even the initial "36439 BYTES FREE" is built-in to that first message. PRINT SIZE immediately after would produce 36592.

The jump table at the start of the RAM Monitor has different addresses to the ROM Monitor ( see subroutines and workarea of the ROM Monitor 1Z-013A ), they are listed below, all addresses are in hex. Some appear to be unused while others are duplicated. The tables show only a short description this time. The information about the entry points of the interpreter's commands is listed only here.

The list of RAM Monitor and S-BASIC entry points and work area adresses is not a complete list, but it might assist those of you who are delving into the interpreter with your disassembler.

S-BASIC entry points / work area
Cold start monitor / BASC
Get line to workarea adressed by DE ( unused, all calls to $004A )
New line
New line if the cursor isn't positioned at line begin
Print space
Print tab. Sets the cursor to the next tab position
Print character stroed in Accu
Print message pointed to by DE ( unused, all calls to $0051 )
Print message pinted to by DE. Cursor characters are included ( unused, all calls to $0051 )
$001B check if key is pressed
$001E check if SHIFT-BREAK is pressed
Write info header to tape
Write data to tape
Read info header from tape
Read data from tape
Verify tape and program in RAM
Melody play
Time set
Read time
Set tempo
Melody start
Melody stop
Get line from keyboard
$004D printer flag.
$16 ( or each other value >0 ) = plot on
$00 = plot off
$004E CONSOLE flag.
$00 = scrolling is suppressed
each other value executes scrolling
$004F input buffer length
$FF = BASIC 255 characters
$64 = monitor 100 characters
$0050 flag tape output
e.g. if >0 then a SAVE or LOAD command called by a program is active
$0051 Print message pointed to by DE
$0054 current cursor position X
$0055 current cursor position Y
$0056 points to the first line to be scrolled ( Ymin )
$0057 number of lines to be scrolled ( Ymax )
$0058 check if key is pressed ( no repeat is possible )
$005B points to the first column to be scrolled ( Xmin )
$005C number of columns to be scrolled ( Xmax )
$005D bits 3 - 0 background colour
bits 7 - 4 character colour
$005E clear character $00 to clear the screen
$005F contains character of the last key pressed
$0060 actual cursor character ( display code used )
$43 = alpha
$EF = graphic lower case
$FF = graphic
$0061 joystick subroutine
$0064 AM / PM flag
$00 = AM
$01 = PM
$0065 joystick value analog
$0066 joystick value digital
$0067 -
Control code address table. Contains the address to jump to after the "PRINT CHR$"-statement or a key with the CTRL-key down, as explained here ( The "NOACT" shown there means it will effect in an immediate return ).
$00A7 -
Concatination flag of Basic lines 0 ( $00A6 ) - 50 ( $00D9 ). Used for identification of logical lines which logically represent a Basic line listed on the screen. A Basic line can have up to 255 characters and by this it can exceed the length of a physical line which has only the length of a 40-character screen line. Basic uses this area to remember which lines are logically one Basic line. The contents of this area is important e.g. while editing a Basic line.
Example: If $00A7 contains $00 00 01 01 00 ... then physical lines 2 and 3 belong logically to the physical line 1. Note, line 1 is addressed by $00A8 and note, line 0 has only one logical line ( no concatination ). A "$01" flag indicates it is a logical line to the previous line containing $00 ( or $01 if more than 2 lines are logically one Basic line; as shown in the example ).
$00A7 - $00BF relates to the visible area and $00C0 - $00D8 to the unvisible area which is shown if scrolling is performed by using the SHIFT / Cursor UP/DOWN keys. $00D9 is used during a scroll operation as a workarea.
$00EA Routine called from PEEK to access the V-RAM
$00F2 used to POKE to V-RAM
$011C -
table of 4 forbidden / suppressed printer characters ( HOME, CLR, DEL, INS )
$04A0 checks for Break condition
Z-flag is set on return if the condition is true
$04B6 Display to ASCII converter ( Accu )
$04CD ASCII to Display code converter ( Accu )
$0EFC -
ASCII to Display ( and vice versa ) conversion code table. $F0 = non-displayable character
$0A32 Tempo ( 1 - 7; 1 = quick, 7 = slow )
$0A33 -
unused by Basic
$0A37 Duration
$0A38 Octave ( 1 = upper, 2 = middle, 3 = lower )
$0A39 Frequency ( ratio )
$0FFC -
is used by several routines as workarea, e.g. tape header, preparation of the USING-format, keyboard input buffer.
Note The area $1000 - $11FF cannot be used for any purposes if you want to prevent loss of data during RESET and returning to Basic. In this case the monitor uses this area.
$0FFC -
tape header area
$0FFC file type stored
$0FFD file name
$100E file size
$1010 load address
$1012 executin address
$110F last line input buffer
$121D -
table used by keyboard-matrix to ASCII conversion
$131D -
conversin table of additional defined CTRL-keys
$1322 -
DEF KEY function table in ASCII, any alterations to DEF KEY will be stored here. 10 entries; each is 16 bytes in length and each first byte contains the length of the text
$13C2 cold start of the RAM monitor
$141C -
table contains monitor commands ( D, M, P, G, F, R, S, L, V, T ) and their related entry points
$1819 monitor output flag
>$00 output to printer
$1822 is where BASIC jumps to after loading, where the intial screen message is displayed and subsequently gets wiped out as RAM is cleared p to $FF00. If you don't want everything cleared then this is the place to make alterations. Cold start Basic used only once at startup.
$1848 is where all future returns to BASIC from ROM Monitor jump, so keeping RAM intact, Warm- / RESET-start of BASIC.
$1869 is where "Ready" gets displayed
$1872 is the main edit loop
$18FB starts the execution loop
$1915 check for TRON ( flag $38DD )
$1930 Check BREAK
$19D0 is the routine for converting MZ-80K to MZ-700 programs addressed by HL ( program line address )
$20C7 is the error table and numbers
$2173 displays the current line number
$21A7 converts HL-hex to ASCII and stores it to $6A26
$2287 TRON routine, finishes at $229E
$242F -
which although contains code, is not used
$2AF5 starts the first keyword table, up to $2CA8
$2CA9 -
is completely empty and this seems a likely place for any additions you might like to make. If you use a tolkit this is the most favoured spot for it, so dump this out before making changes.
$30A9 sees the start of the second keyword table up to the start of keyword addresses. If you are using a toolkit or a peripheral device which needs extra code placed somewhere, check on this area before adding any extra routines.
$30A9 -
keyword table for 2 bytes tokens prefixed by $FF ( commands )
$3147 -
is the keyword address table for tokens $80 - $DF
$3207 -
is the keyword address table for tokens prefixed by $FE
$3265 -
keyword table for 2 bytes tokens prefixed by $FF ( functions )
$3807 is the address of GOTO. In most versions of Basic GOTO or GOSUB start their searches for a line number from the top of the program, which on a long listing or a frequently used subroutine can slow down the running, the 700 BASIC doesn't.
When a Basic line is entered with either of these statements the token keyword, $80 for GOTO or $81 for GOSUB, is followed by $0B and the line number. When the program has been run once the byte which follows the tokens gets changed to $0C, and the bytes containing the line number get altered to the absolute address in memory where the GOTO line is stored, so cutting down the time taken searching for program lines. Naturally each time a line is added or edited these byte get changed back to $0B followed by line number, as their absolute addresses might then be different.
For more details read the Basic Internals.
$38D3 -
is where pointers to the current program are stored
$38D3 string workarea pointer
$38D5 Stack pointer at start of interpreting ( e.g. by RUN, $FE00 )
$38D7 number of files allowed

on error flag
$00 = inactive
$01 = active
$02 = Resume active

$38D9 CONT flag
$00 = can't continue ( set by GOTO, RUN, edit new line )
$01 = can continue ( set by STOP, END )
$38DA address of text-string area
$38DC unused
$38DD Trace flag
$01 = TRON
$00 = TROFF
$38DE unused
$38DF AUTO flag
$00 = inactive
$01 = active
$38E0 pointer to next Basic line to interprete
$36E2 AUTO first line number ( line number for editor )
$38E4 AUTO increment count
$38E6 current line number in work ( or $FFFF if not interpreting )
$38E8 address of the line-in-error. ( ON ERROR GOTO / GOSUB )
$38EA line-number of the line-in-error
$38EC address of next line behind the line-in-error
$38EE address of the error in the line-in-eror
$38F0 address of byte interpreting
$38F2 error number
$38F3 address pointer of the current line for CONT ( set by BREAK, END, STOP )
$38F5 current line number for CONT
$38F7 address pointer of the next line for CONT
$38F9 -
$38FB workarea for loop variables ( e.g. FOR A...NEXT A )
$38FD -
$3900 counter of null-command ( unused routine )
$3901 option base flag ( unused )
$3D86 is the binary to decimal conversion routine; HL-hex into ASCII and stored to (DE)
$3DB2 used by binary / decimal conversion, divides HL by DE and stores one digit ASCII result
$4795 turns basic line addressed by (DE) into tokens addressed by (HL)
$49CD turns tokens addressed by (HL) back to text for listing addressed by (DE)
$4B72 -
text of error messages ( each suffixed by $00 )
$4D50 checks for integer less than 256 ( e.g. used on CHR$ )
(HL) points to the integer; result to accu ( and DE )
$4D65 checks for integer over 255 ( e.g. used on MOVE )
(HL) points to the integer; result to DE
$4DCB plotter mode flag ( 1 text mode, 2 = graph )
$4DCD print size flag. Contains $4E for normal ( 40 characters ), $4C for large ( 26 characters ), and $53 for small ( 80 characters )
$4EE0 flag for co-ordinates ( $44 = LINE, $4A = RLINE, $4D = MOVE, $52 = RMOVE )
$528B checks all maths expressions and sets pointer (DE) to the result
$6A0C -
$6A12 pointer to math memory 4
$6A14 pointer to math memory 3
$6A16 pointer to math memory 2
$6A18 pointer to math memory 1
$6A1A pointer to math memory COS(argument)
$6A1C pointer to math memory SIN(argument)
$6A1E sign of result trig.
$6A1F workarea RND
$6A21 workarea EXP
$6A22 sign EXP(argument)
$6A23 workarea EXP
$6A24 exponent for LN
$6A25 -
workarea for ASCII digits
$6A36 decimal point-place
$6A37 right-of-comma positions
$6A58 counter length of line; workarea for conversion Basic line to tokens
$6A59 pointer to result for maths routines
$6A5B sign of result + / -
$6A5C workarea for stack pointer
$6A5E workarea for stack pointer
$6A60 overflow flag 0 / 1
$6A61 exponent result *
$6A63 -
$6A65 type of variable
$6A66 workarea exponent
$6A67 -
workarea mantissa
$6A6E workarea exponent
$6A6F -
workarea mantissa
$6A76 workarea exponent
$6A77 -
workarea mantissa
$6A7E pointer to real number
$6A80 flag skip spaces in number
$6A81 counter left-of-comma positions
$6A82 flag digit ready
$6A84 flag decimal-point
$6AB3 -
more pointers to the current program
$6AB3 end of program; pointer to variables / defined functions
$6AB5 address of string variable storage
$6AB7 address for next string variable ( free area )
$6AB9 pointer to maths memory
$6ABB pointer to start of RAM ( changed by LIMIT ). The area pointed to can be used e.g. as resident part of machine code programs.
$6ABD top of RAM ( changed by LIMIT; $FF00 )
$6ABF pointer to Basic file ( $6BCF )
$6AC1 -
workarea direct mode; conversion to tokens
$6BCF Basic program text area
RAM Monitor entry points
$141C -
table contains monitor commands ( D, M, P, G, F, R, S, L, V, T ) and their related entry points
$143A Print ( toggles $1819 $01 / $00 )
$1469 Load
$14B8 Return
$154A Dump
Memory set
$15F4 Find
$1819 monitor output flag
>$00 output to printer

Go to the top of this page Home

last updated September 18, 2002