4 ; Useful things in the BASIC environment
6 ; © 1994-1998 Straylight
9 ;----- Licensing note -------------------------------------------------------
11 ; This file is part of Straylight's BASIC Assembler Supplement.
13 ; BAS is free software; you can redistribute it and/or modify
14 ; it under the terms of the GNU General Public License as published by
15 ; the Free Software Foundation; either version 2, or (at your option)
18 ; BAS is distributed in the hope that it will be useful,
19 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ; GNU General Public License for more details.
23 ; You should have received a copy of the GNU General Public License
24 ; along with BAS. If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 ; This file contains symbolic names for the useful bits which BASIC puts
30 ; after R14 when it CALLs a piece of code.
34 ; --- Miscellaneous useful things ---
36 bEnv_return # 4 ;Return address after CALL
38 ; --- Offsets from ARGP (in R8 of all places) ---
40 bEnv_strAcc # 4 ;Ptr to string accumulator
41 bEnv_page # 4 ;Current program PAGE
42 bEnv_top # 4 ;Current program TOP
43 bEnv_loMem # 4 ;Current variable start
44 bEnv_hiMem # 4 ;Current stack end
45 bEnv_memLimit # 4 ;Limit of available memory
46 bEnv_fsa # 4 ;Free space start
47 bEnv_tally # 4 ;Value of COUNT
48 bEnv_timeOff # 4 ;Diff tween TIME and OS_Word
49 bEnv_escWord # 4 ;Exception flag word
50 bEnv_widthLoc # 4 ;Value of width-1
52 ; --- Internal routines ---
54 ; Some corruptions documented. Bear in mind that there may
57 bEnv_varind # 4 ;Return value of lvalue
58 ;Entry: R0 == address of lv
65 ; 8<<28 == fp in R0-R3
67 bEnv_storea # 4 ;Store a value in lvalue
68 ;Entry: R0-R3 == value
74 ;Exit: R0-R7 corrupted
76 bEnv_ststore # 4 ;Stores a string in variable
77 ;Entry: Can't remember
80 bEnv_lvblnk # 4 ;Find a named lvalue
84 ;Exit: R0 == address of lv
88 ; EQ, CC => use CREATE
90 bEnv_create # 4 ;Creates a variable
91 ;Entry: Set up from LVBLNK
92 ;Exit: R0 == address of lv
95 bEnv_expr # 4 ;Evaluates an expression
97 ; R11 points to string
101 ; NE, PL => int value
103 bEnv_match # 4 ;Tokenises a string
104 ;Entry: R1 == cr term string
106 ; R3 == 0 (parse lval)
108 ; R4 == 0/&8D (line no)
109 ;Exit: R0, R3, R4 corrupted
114 ; bit 8 => bad line no
117 bEnv_tokenAddr # 4 ;Untokenises a string
119 ; R12 == ptr to next ch
120 ;Exit: R1 == ptr to string
125 ; --- Floating point routines ---
127 ; * means R4-R7 corrupted, and errors (e.g. overflow)
130 ; In all cases, (R0-R3) may be modified, although the FP
131 ; value will be preserved (e.g. for normalisation).
133 ; In FIX and FLOAT, R9 is changed to indicate the new type.
135 # 8 ;Ask Roger/Sophie!
136 bEnv_fSta # 4 ;[R9] <- (R0-R3)
137 bEnv_fLda # 4 ;(R0-R3) <- [R9]
139 bEnv_fAdd # 4 ;(R0-R3) <- [R9] + (R0-R3) *
140 bEnv_fSub # 4 ;(R0-R3) <- [R9] - (R0-R3) *
141 bEnv_fMul # 4 ;(R0-R3) <- [R9] * (R0-R3) *
142 bEnv_fDiv # 4 ;(R0-R3) <- [R9] / (R0-R3) *
144 bEnv_float # 4 ;(R0-R3) <- R0, R9 <- FLOAT
145 bEnv_fix # 4 ;R0 <- (R0-R3), R9 <- INT
146 bEnv_fSqrt # 4 ;(R0-R3) <- sqrt(R0-R3) *
148 ;----- That's all, folks ----------------------------------------------------