]> git.sur5r.net Git - cc65/blob - libsrc/common/raise.s
Clean wherey.s
[cc65] / libsrc / common / raise.s
1 ;
2 ; Ullrich von Bassewitz, 2003-03-14
3 ;
4 ; int __fastcall__ raise (int sig);
5 ;
6
7         .import         jmpvec
8
9         .include        "signal.inc"
10
11
12 ;----------------------------------------------------------------------------
13 ; int __fastcall__ raise (int sig);
14
15
16 _raise:
17         cpx     #0
18         bne     invalidsig
19         cmp     #SIGCOUNT
20         bcs     invalidsig
21
22 ; Save the signal number low byte, then setup the function vector
23
24         pha
25         asl     a
26         tax
27         lda     sigtable,x
28         sta     jmpvec+1
29         lda     sigtable+1,x
30         sta     jmpvec+2
31                             
32 ; Reset the signal handler to SIG_DFL (I don't like this because it may
33 ; introduce race conditions, but it's the simplest way to satisfy the 
34 ; standard).
35
36         lda     #<__sig_dfl
37         sta     sigtable,x
38         lda     #>__sig_dfl
39         sta     sigtable+1,x
40
41 ; Restore the signal number and call the function
42
43         pla                     ; Low byte
44         ldx     #0              ; High byte
45         jsr     jmpvec          ; Call signal function
46
47 ; raise() returns zero on success and any other value on failure
48
49         lda     #0
50         tax
51 invalidsig:
52         rts
53
54