; ; error.s ; ; Generation and handling of errors ; ; © 1995 Straylight ; ;----- Standard header ------------------------------------------------------ GET libs:header GET libs:swis GET libs:stream ;----- External dependencies ------------------------------------------------ GET sh.anchor GET sh.termScript ;----- Main code ------------------------------------------------------------ AREA |TermScript$$Code|,CODE,READONLY ; --- error_report --- ; ; On entry: R0 == error number ; ; On exit: doesn't -- reports error to Termite ; ; Use: Reports an error, attaching the error number etc. and ; terminating the script. EXPORT error_report error_report ROUT ADR R1,tsc_misc ;Point to the misc buffer STR R0,[R1],#4 ;Save the error number away ; --- Find the error string --- ADR R14,errTable ;Point to error table LDR R0,[R14,R0,LSL #2] ;Find the error offset ADD R0,R14,R0 ;And convert that to address ; --- Now build the actual string --- 10error_report LDRB R14,[R0],#1 ;Load byte from error text CMP R14,#0 ;Is this the end yet? STRNEB R14,[R1],#1 ;No -- store the byte BNE %10error_report ;And keep looping until done ; -- Stick `at line' on the end --- ADR R0,error__atLine ;Point to literal string 20error_report LDRB R14,[R0],#1 ;Load byte from text CMP R14,#0 ;Is this the end yet? STRNEB R14,[R1],#1 ;No -- store the byte BNE %20error_report ;And keep looping until done ; --- Now attach the line number --- LDR R0,tsc_line ;Get the line number MOV R2,#256 ;Assume a big buffer SWI OS_ConvertInteger4 ;Attach that to the end ; --- Finally throw the error at Termite --- ADR R0,tsc_misc ;Point to error base B tsc_error ;And return the error error__atLine DCB " at line ",0 ALIGN GET sh.errTable LTORG ; --- error_reportReal --- ; ; On entry: R0 == error block ; ; On exit: doesn't -- reports error to Termite ; ; Use: Reports an error, attaching the error number etc. and ; terminating the script. EXPORT error_reportReal error_reportReal ROUT ADR R1,tsc_misc ;Point to the misc buffer LDR R14,[R0],#4 ;Load the error number STR R14,[R1],#4 ;Save the error number away ; --- Now build the actual string --- 10 LDRB R14,[R0],#1 ;Load byte from error text CMP R14,#0 ;Is this the end yet? STRNEB R14,[R1],#1 ;No -- store the byte BNE %10error_reportReal ;And keep looping until done ; -- Stick `at line' on the end --- ADRL R0,error__atLine ;Point to literal string 20 LDRB R14,[R0],#1 ;Load byte from text CMP R14,#0 ;Is this the end yet? STRNEB R14,[R1],#1 ;No -- store the byte BNE %20error_reportReal ;And keep looping until done ; --- Now attach the line number --- LDR R0,tsc_line ;Get the line number MOV R2,#256 ;Assume a big buffer SWI OS_ConvertInteger4 ;Attach that to the end ; --- Finally throw the error at Termite --- ADR R0,tsc_misc ;Point to error base B tsc_error ;And return the error GET sh.errTable LTORG ;----- That's all, folks ---------------------------------------------------- END