[cc65] Re: signals

From: Jonathan Graham Harston <jgh1arcade.demon.co.uk>
Date: 2005-05-31 02:10:48
> Message-ID: <429B360D.1030200@brahms.demon.co.uk>
 
dominic beesley <dominic@brahms.demon.co.uk> wrote:
> The "standard" is to have the byte after the BRK as an errorcode
> followed by a NULL terminated string. Makes for very compact
> code in the OS ROMS but can be a pain in the arse when writing
> code. (In the Risc OS operating system they recognised this and
> have two forms of each call, one that issues something like BRK
> and one that returns
 
I've interpreted that in light of your post to csa.programmer as
meaning that it's a problem to program with if you don't set up an
error handler, and that you would like to be able to do the
equivalent of using 'X' form SWIs on the BBC, so errors are
returned rather than generated.
 
This reminded me that I was thinking about this myself some time
ago. Following the theme of the RISC OS 'C' compiler, os_*
functions should just call the relevant OS routine, but _kernel_*
calls should put a veneer around the OS call to catch and return
any error.
 
Something like:
._kernel_osfile
lda brkv+0:pha
lda brkv+1:pha
lda _kernel_brktrap and 255:sta brkv+0
lda _kernel_brktrap div 256:sta brkv+1
tsx:stx errorsp
; set up registers for osfile
jsr osfile
; store returned registers
ldx #0:clc
._kernel_osfile_exit
pla:sta brkv+1
pla:sta brkv+0
txa:rts
._kernel_brktrap
ldx errorsp:txs
ldy #0:lda (&fd),y
sec:bcs _kernel_osfile_exit
.errorsp
equb &00
 
There's a way of generalising this for all OS calls instead of
duplicating the veneer each time, and I need to have a dig though
some code notes to work out what the return state should be, and
how the 'C' program finds ERR and REPORT$.
 
> checked on return) would this make Escape handling safer....?
 
You should let Escape set it's escape flag, and let the foreground
program check the escape flag. If some code doesn't respond to
Escape a quickly as you'd like it, it's either because the code
shouldn't be interrupted, or *you* the programmer haven't checked
for escape frequently enough.
 
Escape should *never* change the foreground program flow.
 
-- 
J.G.Harston - jgh@arcade.demon.co.uk - mdfs.net/User/JGH
BBC BASIC for Windows and Internationalisation
  See http://mdfs.net/Software/BBCBasic/Windows/ProgTips
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue May 31 03:00:56 2005

This archive was generated by hypermail 2.1.8 : 2005-05-31 03:00:59 CEST