Mercurial > hg > index.cgi
annotate src/error.s @ 80:bb50ac9fdf37
Checkpoint with very basic integer and floating point arithmetic, untested
This commit has implementations for floating point add, subtract, multiply,
and divide, along with 32 bit signed integer equivalents. These can probably
be optimized and they are untested.
author | William Astle <lost@l-w.ca> |
---|---|
date | Sat, 07 Oct 2023 02:56:59 -0600 |
parents | 5f8f0b0781e8 |
children | a6a53e5c04bd |
rev | line source |
---|---|
75
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
1 *pragmapush list |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
2 *pragma list |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
4 ; The error handler |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
5 ; |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
6 ; Enter with the error number in B. This routine will do some cleanup and handle any ON ERROR GOTO handler that |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
7 ; may be active. |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
8 ; |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
9 ; Note the error message lookup does not need to be efficient which is why the lookup just runs through the list |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
10 ; of error messages in sequence looking for NUL terminators. The specific handling of B (error number) below avoids |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
11 ; issues if there happen to be error codes above 128. |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
12 ERROR clr filenum ; reset display device to console |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
13 jsr writecondnl ; do a newline if needed (will preserve B) |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
14 ldx #errormsg ; point to error message list |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
15 incb ; account for decb below |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
16 bra ERROR1 ; go search for correct message |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
17 ERROR0 lda ,x+ ; end of message? |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
18 bne ERROR0 ; brif not end of message |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
19 ERROR1 decb ; at the correct one? |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
20 bne ERROR0 ; brif not - skip to next one |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
21 ERROR2 jsr writestrconduc ; output error message |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
22 ldu curline ; are we in immediate mode? |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
23 beq ERROR3 ; brif so |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
24 ldx #inmsg ; point to " in " |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
25 jsr writestrconduc ; output " in " |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
26 ldd 2,u ; get line number |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
27 jsr print_uint16d ; display the line number |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
28 ERROR3 lds freetop ; reset the stack pointer (error routine could be called anywhere) |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
29 clr ,-s ; reset the call stack |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
30 sts stackptr |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
31 jmp immediate ; go back to immediate mode |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
32 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
33 ; Error messages |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
34 ; |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
35 ; Each error begins with a deferr macro invocation which will define a symbol err_slug with the next error number |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
36 ; |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
37 ; deferr slug |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
38 ; |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
39 ; This is then followed by the error message defined with fcn. |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
40 ; |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
41 ; Real error numbers start at 1; 0 is used to indicate no error. |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
42 *pragmapush list |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
43 *pragma nolist |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
44 __errnum set 0 |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
45 deferr macro noexpand |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
46 err_{1} equ __errnum |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
47 __errnum set __errnum+1 |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
48 endm |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
49 *pragmapop list |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
50 errormsg deferr none |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
51 fcn 'No error' |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
52 deferr nf |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
53 fcn 'NEXT without FOR' |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
54 deferr sn |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
55 fcn 'Syntax error' |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
56 deferr ul |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
57 fcn 'Undefined line number' |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
58 deferr rg |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
59 fcn 'RETURN without GOSUB' |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
60 deferr ov |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
61 fcn 'Overflow' |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
62 deferr tm |
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
63 fcn 'Type mismatch' |
80
bb50ac9fdf37
Checkpoint with very basic integer and floating point arithmetic, untested
William Astle <lost@l-w.ca>
parents:
75
diff
changeset
|
64 deferr div0 |
bb50ac9fdf37
Checkpoint with very basic integer and floating point arithmetic, untested
William Astle <lost@l-w.ca>
parents:
75
diff
changeset
|
65 fcn 'Division by zero' |
75
5f8f0b0781e8
Split some code into separate files for easier management (3)
William Astle <lost@l-w.ca>
parents:
diff
changeset
|
66 *pragmapop list |