-
Notifications
You must be signed in to change notification settings - Fork 5
/
Main.asm
178 lines (130 loc) · 4.44 KB
/
Main.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
;#dialect=RASM
;Current progress:
;(Mostly) fully reverse engineered as far as **TK
;'Unassembled'[1] Amstrad CPC6128 BASIC 1.1 Source Code
;[1] 'Unassembled' meaning that this code can be modified and reassembled.
;(As far as I can tell) all links etc have been converted to labels etc in
;such a way that the code can be assembled at a different target address
;and still function correctly (excepting code which must run at a specific
;address).
;Based on the riginal commented disassembly at:
; http://cpctech.cpc-live.com/docs/basic.asm
;There are two versions of this file: a single monolithic version and
;one which has been broken out into separate 'includes'. The latter may
;prove better for modification, assembly and re-use. The former for
;exploration and reverse engineering.
;For more details see: https://github.com/Bread80/Amstrad-CPC-BASIC-Source
;and http://Bread80.com
include "Initialisation.asm"
;;<< PROGRAM ENTRY ROUTINES
;;< REPL loop, EDIT, AUTO, NEW, CLEAR (INPUT)
include "ProgramEntry.asm"
;;<< (TEXT) STREAM MANAGEMENT
include "Streams.asm"
;;<< SCREEN HANDLING FUNCTIONS
include "Screen.asm"
;;<< STREAM I/O
;;< Low level I/O via streams, WIDTH and EOF
include "StreamIO.asm"
;;<< LOW LEVEL KEYBOARD HANDLING
;;< including BREAK key handler
include "Keyboard.asm"
;;<< GRAPHICS FUNCTIONS
include "Graphics.asm"
;;<< CONTROL FLOW
;;< FOR, IF, GOTO, GOSUB, WHILE
include "ControlFlow.asm"
;;<< ERROR AND EVENT HANDLERS
;;< ON xx, DI, EI, AFTER, EVERY, REMAIN
include "EventsExceptions.asm"
;;<< FIND ENDS OF CONTROL LOOPS
;;< Don't have a good phrase for this :(
include "ControlFlowUtils.asm"
;;<< BASIC INPUT BUFFER
;;< As used by EDIT and INPUT etc.
include "BasicInput.asm"
;;<< EXCEPTION HANDLING
;;< Includes ERROR, STOP, END, ON ERROR GOTO 0 (not ON ERROR GOTO n!), RESUME and error messages
include "Errors.asm"
;;<< EXPRESSION EVALUATION
;;< Includes prefix operators and various lookup tables (operators, system vars etc.)
include "ExprEvaluator.asm"
;;<< SYSTEM VARIABLES
;;< (most of them). And the @ prefix operator.
include "SystemVars.asm"
;;<< DEF and DEF FN
include "DEFFN.asm"
;;<< FUNCTION LOOK UP TABLE
include "FunctionTable.asm"
;;<< MATHS FUNCTIONS MIN, MAX and ROUND
include "MathsAgain.asm"
;;<< FILE I/O COMMANDS
;;< CAT, OPENIN, OPENOUT, CLOSEIN, CLOSEOUT
include "FileIO.asm"
;;<< SOUND FUNCTIONS
include "Sound.asm"
;;<< INPUT FUNCTIONS
;;< INKEY, JOY, KEY (DEF). Also SPEED (WRITE/KEY/INK)
include "Input.asm"
;;<< (REAL) MATHS FUNCTIONS
;;< Including ^ and random numbers
include "MathsFunctions.asm"
;;<< VARIABLE ALLOCATION AND ASSIGNMENT
;;< DEFINT/REAL/STR, LET, DIM, ERASE
;;< (Lots more work to do here)
include "VariableArrayFN.asm"
;;<< (TEXT) DATA INPUT
;;< (LINE) INPUT, RESTORE, READ (not DATA)
include "DataInput.asm"
;;<< INTEGER MATHS
;;< (used both internally and by functions)
include "IntegerMaths.asm"
;;<< PROGRAM EXECUTION
;;< Execute tokenised code (except expressions)
;;< Includes token handling utilities, TRON, TROFF,
;;< and the command/statement look up table.
include "Execution.asm"
;;<< TOKENISING SOURCE CODE
include "Tokenising.asm"
;;<< LIST AND DETOKENISING BACK TO ASCII
include "Detokenising.asm"
;;<< KEYWORD LOOK UP TABLES
;;< And associated functions
include "KeywordLUTs.asm"
;;<< PROGRAM EDITING AND MANIPULATION
;;< DELETE, RENUM, DATA, REM, ', ELSE and
;;< a bunch of related utility stuff
include "ProgramManipulation.asm"
;;<< FILE HANDLING
;;< RUN, LOAD, CHAIN, MERGE, SAVE
include "LoadSaveRun.asm"
;;<< STRINGS TO NUMBERS
include "StringsToNumbers.asm"
;;<< NUMBERS TO STRINGS
include "NumbersToStrings.asm"
;;<< PEEK, POKE, INP, OUT, WAIT, |BAR commands, CALL
include "PeekPokeIOBarCall.asm"
;;<< TEXT OUTPUT (ZONE, PRINT, WRITE)
include "TextOutput.asm"
;;<< MEMORY ALLOCATION FUNCTIONS
;;< Includes MEMORY, SYMBOL (AFTER)
include "MemoryAllocation.asm"
;;<< STRING FUNCTIONS
;;<including the string iterator
include "StringFunctions.asm"
;;<<STRINGS AREA
;;<Including the string stack, FRE and the garbage collector
include "StringsArea.asm"
;;<< INFIX OPERATORS
;;< Infix +, -, *, / etc. including boolean operators
include "InfixOperators.asm"
;;<< TYPE CONVERSIONS AND ROUNDING
;;< (from numbers to numbers)
include "TypeConversions.asm"
;;<< ACCUMULATOR UTILITIES
;;< Store values to accumulator, get values from accumulator,
;;< and accumulator type conversions
include "Accumulator.asm"
;;<< UTILITY ROUTINES
;;< Assorted memory copies, table lookups etc.
include "Utilities.asm"