4 ; Generation and handling of errors
9 ;----- Standard header ------------------------------------------------------
16 ;----- External dependencies ------------------------------------------------
21 ;----- Main code ------------------------------------------------------------
23 AREA |TermScript$$Code|,CODE,READONLY
25 ; --- error_report ---
27 ; On entry: R0 == error number
29 ; On exit: doesn't -- reports error to Termite
31 ; Use: Reports an error, attaching the error number etc. and
32 ; terminating the script.
37 ADR R1,tsc_misc ;Point to the misc buffer
38 STR R0,[R1],#4 ;Save the error number away
40 ; --- Find the error string ---
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
46 ; --- Now build the actual string ---
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
53 ; -- Stick `at line' on the end ---
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
61 ; --- Now attach the line number ---
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
67 ; --- Finally throw the error at Termite ---
69 ADR R0,tsc_misc ;Point to error base
70 B tsc_error ;And return the error
72 error__atLine DCB " at line ",0
79 ; --- error_reportReal ---
81 ; On entry: R0 == error block
83 ; On exit: doesn't -- reports error to Termite
85 ; Use: Reports an error, attaching the error number etc. and
86 ; terminating the script.
88 EXPORT error_reportReal
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
95 ; --- Now build the actual string ---
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
102 ; -- Stick `at line' on the end ---
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
110 ; --- Now attach the line number ---
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
116 ; --- Finally throw the error at Termite ---
118 ADR R0,tsc_misc ;Point to error base
119 B tsc_error ;And return the error
125 ;----- That's all, folks ----------------------------------------------------