Initial revision
[ssr] / StraySrc / Libraries / BAS / src / s / vars
1 ;
2 ; vars.s
3 ;
4 ; Setting up useful variables for BAS
5 ;
6 ; © 1994-1998 Straylight
7 ;
8
9 ;----- Licensing note -------------------------------------------------------
10 ;
11 ; This file is part of Straylight's BASIC Assembler Supplement.
12 ;
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)
16 ; any later version.
17 ;
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.
22 ;
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.
26
27 ;----- Standard header ------------------------------------------------------
28
29 GET libs:header
30 GET libs:swis
31
32 GET libs:stream
33
34 ;----- External dependencies ------------------------------------------------
35
36 GET sh.bas
37 GET sh.basTalk
38
39 ;----- Main code ------------------------------------------------------------
40
41 AREA |BAS$$Code|,CODE,READONLY
42
43 ; --- vars__setAscending ---
44 ;
45 ; On entry: R3 == pointer to a name table
46 ;
47 ; On exit: R3 points past the table
48 ;
49 ; Use: Sets the variables named in the given table to have integer
50 ; values from 0 upwards. The table contains null-terminated
51 ; strings and is terminated by a null string.
52
53 vars__setAscending ROUT
54
55 STMFD R13!,{R0-R2,R4,R14} ;Save some registers
56 MOV R4,#0 ;Start counting at 0
57 00 MOV R0,R3 ;Point at the string
58 MOV R2,R4 ;Get the next value to set
59 LDRB R14,[R3],#1 ;Load first byte from string
60 CMP R14,#0 ;Is it the end of the table?
61 LDMEQFD R13!,{R0-R2,R4,PC}^ ;Yes -- we've finished then
62 ADD R4,R4,#1 ;Increment the counter
63 10 LDRB R14,[R3],#1 ;Load next byte from string
64 CMP R14,#1 ;Alternative name?
65 SUBEQ R4,R4,#1 ;Yes -- don't bump counter
66 CMPNE R14,#0 ;Is it the end yet?
67 BNE %10vars__setAscending ;No -- go round for more
68 BL bTalk_create ;Create the variable
69 BL bTalk_store ;Store the value away
70 B %00vars__setAscending ;Set the next variable
71
72 LTORG
73
74 ; --- vars_set ---
75 ;
76 ; On entry: --
77 ;
78 ; On exit: --
79 ;
80 ; Use: Sets up variable names for registers (normal and APCS) and
81 ; also for condition codes.
82
83 EXPORT vars_set
84 vars_set ROUT
85
86 STMFD R13!,{R0,R14} ;Save some registers
87 ADR R3,vars__names ;Point to big name table
88 BL vars__setAscending ;Standard registers
89 BL vars__setAscending ;APCS registers
90 BL vars__setAscending ;Standard condition names
91 LDMFD R13!,{R0,PC}^ ;And return to caller
92
93 vars__names DCB "R0",1,"r0",0
94 DCB "R1",1,"r1",0
95 DCB "R2",1,"r2",0
96 DCB "R3",1,"r3",0
97 DCB "R4",1,"r4",0
98 DCB "R5",1,"r5",0
99 DCB "R6",1,"r6",0
100 DCB "R7",1,"r7",0
101 DCB "R8",1,"r8",0
102 DCB "R9",1,"r9",0
103 DCB "R10",1,"r10",0
104 DCB "R11",1,"r11",0
105 DCB "R12",1,"r12",0
106 DCB "R13",1,"SP",1,"r13",1,"sp",0
107 DCB "R14",1,"LR",1,"LK",1,"r14",1,"lr",1,"lk",0
108 DCB "R15",1,"PC",1,"r15",1,"pc",0
109 DCB 0
110
111 DCB "a1",0
112 DCB "a2",0
113 DCB "a3",0
114 DCB "a4",0
115 DCB "v1",0
116 DCB "v2",0
117 DCB "v3",0
118 DCB "v4",0
119 DCB "v5",0
120 DCB "v6",1,"sb",0
121 DCB "v7",1,"sl",0
122 DCB "fp",0
123 DCB "ip",0
124 DCB "sp",0
125 DCB "lr",0
126 DCB "pc",0
127 DCB 0
128
129 DCB "EQ",1,"eq",1,"ZS",1,"zs",0
130 DCB "NE",1,"ne",1,"ZC",1,"zc",0
131 DCB "CS",1,"cs",1,"HS",1,"hs",0
132 DCB "CC",1,"cc",1,"LO",1,"lo",0
133 DCB "MI",1,"mi",1,"NS",1,"ns",0
134 DCB "PL",1,"pl",1,"NC",1,"nc",0
135 DCB "VS",1,"vs",0
136 DCB "VC",1,"vc",0
137 DCB "HI",1,"hi",0
138 DCB "LS",1,"ls",0
139 DCB "GE",1,"ge",0
140 DCB "LT",1,"lt",0
141 DCB "GT",1,"gt",0
142 DCB "LE",1,"le",0
143 DCB "AL",1,"al",0
144 DCB "NV",1,"nv",0
145 DCB 0
146
147 LTORG
148
149 ;----- That's all, folks ----------------------------------------------------
150
151 END