]> git.sur5r.net Git - cc65/blob - libsrc/common/stkcheck.s
This commit was generated by cvs2svn to compensate for changes in r2,
[cc65] / libsrc / common / stkcheck.s
1 ;
2 ; Ullrich von Bassewitz, 18.08.1998
3 ;
4 ; Stack checker
5 ;
6
7
8         .export         _stkcheck, __stksafety
9         .import         pushax, exit
10         .import         __hend
11         .importzp       sp
12
13 .data
14 __stksafety:
15         .word   64                      ;
16
17 .code
18 _stkcheck:
19         clc
20         lda     __hend
21         adc     __stksafety
22         tax                             ; Remember low byte
23         lda     __hend+1
24         adc     __stksafety+1
25
26         cmp     sp+1
27         bcc     Ok
28         bne     L1
29         cpx     sp
30         bcc     Ok
31
32 ; Stack overflow
33
34 L1:     inc     sp+1                    ; Create 256 bytes of space
35         ldx     #0
36         lda     #4
37         jsr     pushax
38         jmp     exit
39
40 ; All is well
41
42 Ok:     rts
43
44
45
46
47
48