chiark / gitweb /
Initial revision
[ssr] / StraySrc / Libraries / Sapphire / sail / _s / error
1 ;
2 ; error.s
3 ;
4 ; Generation and handling of errors
5 ;
6 ; © 1995 Straylight
7 ;
8
9 ;----- Standard header ------------------------------------------------------
10
11                 GET     libs:header
12                 GET     libs:swis
13
14                 GET     libs:stream
15
16 ;----- External dependencies ------------------------------------------------
17
18                 GET     sh.anchor
19                 GET     sh.termScript
20
21 ;----- Main code ------------------------------------------------------------
22
23                 AREA    |TermScript$$Code|,CODE,READONLY
24
25 ; --- error_report ---
26 ;
27 ; On entry:     R0 == error number
28 ;
29 ; On exit:      doesn't -- reports error to Termite
30 ;
31 ; Use:          Reports an error, attaching the error number etc. and
32 ;               terminating the script.
33
34                 EXPORT  error_report
35 error_report    ROUT
36
37                 ADR     R1,tsc_misc             ;Point to the misc buffer
38                 STR     R0,[R1],#4              ;Save the error number away
39
40                 ; --- Find the error string ---
41
42                 ADR     R14,errTable            ;Point to error table
43                 LDR     R0,[R14,R0,LSL #2]      ;Find the error offset
44                 ADD     R0,R14,R0               ;And convert that to address
45
46                 ; --- Now build the actual string ---
47
48 10error_report  LDRB    R14,[R0],#1             ;Load byte from error text
49                 CMP     R14,#0                  ;Is this the end yet?
50                 STRNEB  R14,[R1],#1             ;No -- store the byte
51                 BNE     %10error_report         ;And keep looping until done
52
53                 ; -- Stick `at line' on the end ---
54
55                 ADR     R0,error__atLine        ;Point to literal string
56 20error_report  LDRB    R14,[R0],#1             ;Load byte from text
57                 CMP     R14,#0                  ;Is this the end yet?
58                 STRNEB  R14,[R1],#1             ;No -- store the byte
59                 BNE     %20error_report         ;And keep looping until done
60
61                 ; --- Now attach the line number ---
62
63                 LDR     R0,tsc_line             ;Get the line number
64                 MOV     R2,#256                 ;Assume a big buffer
65                 SWI     OS_ConvertInteger4      ;Attach that to the end
66
67                 ; --- Finally throw the error at Termite ---
68
69                 ADR     R0,tsc_misc             ;Point to error base
70                 B       tsc_error               ;And return the error
71
72 error__atLine   DCB     " at line ",0
73                 ALIGN
74
75                 GET     sh.errTable
76
77                 LTORG
78
79 ; --- error_reportReal ---
80 ;
81 ; On entry:     R0 == error block
82 ;
83 ; On exit:      doesn't -- reports error to Termite
84 ;
85 ; Use:          Reports an error, attaching the error number etc. and
86 ;               terminating the script.
87
88                 EXPORT  error_reportReal
89 error_reportReal ROUT
90
91                 ADR     R1,tsc_misc             ;Point to the misc buffer
92                 LDR     R14,[R0],#4             ;Load the error number
93                 STR     R14,[R1],#4             ;Save the error number away
94
95                 ; --- Now build the actual string ---
96
97 10              LDRB    R14,[R0],#1             ;Load byte from error text
98                 CMP     R14,#0                  ;Is this the end yet?
99                 STRNEB  R14,[R1],#1             ;No -- store the byte
100                 BNE     %10error_reportReal     ;And keep looping until done
101
102                 ; -- Stick `at line' on the end ---
103
104                 ADRL    R0,error__atLine        ;Point to literal string
105 20              LDRB    R14,[R0],#1             ;Load byte from text
106                 CMP     R14,#0                  ;Is this the end yet?
107                 STRNEB  R14,[R1],#1             ;No -- store the byte
108                 BNE     %20error_reportReal     ;And keep looping until done
109
110                 ; --- Now attach the line number ---
111
112                 LDR     R0,tsc_line             ;Get the line number
113                 MOV     R2,#256                 ;Assume a big buffer
114                 SWI     OS_ConvertInteger4      ;Attach that to the end
115
116                 ; --- Finally throw the error at Termite ---
117
118                 ADR     R0,tsc_misc             ;Point to error base
119                 B       tsc_error               ;And return the error
120
121                 GET     sh.errTable
122
123                 LTORG
124
125 ;----- That's all, folks ----------------------------------------------------
126
127                 END