X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libsrc%2Fruntime%2Fstkchk.s;h=73df0991782ab65594b4a8d48de525aaf824385e;hb=85885001b133e2dc320b6f6459259afa69784ca8;hp=ee0b7144c80fc7316fc5d611f970bb562394454d;hpb=44fd1082ae807a0b6b4046c65914e20a7e27101c;p=cc65 diff --git a/libsrc/runtime/stkchk.s b/libsrc/runtime/stkchk.s index ee0b7144c..73df09917 100644 --- a/libsrc/runtime/stkchk.s +++ b/libsrc/runtime/stkchk.s @@ -13,14 +13,14 @@ ; its' bounds. ; - .export stkchk, cstkchk - .constructor initstkchk, 25 - .import __STACKSIZE__ ; Linker defined - .import pusha0, _exit - .importzp sp - - ; Use macros for better readability - .macpack generic + .export stkchk, cstkchk + .constructor initstkchk, 25 + .import __STACKSIZE__ ; Linker defined + .import pusha0, _exit + .importzp sp + + ; Use macros for better readability + .macpack generic .macpack cpu @@ -30,22 +30,22 @@ .segment "INIT" -.proc initstkchk +.proc initstkchk - lda sp - sta initialsp - sub #<__STACKSIZE__ - sta lowwater - lda sp+1 - sta initialsp+1 - sbc #>__STACKSIZE__ + lda sp + sta initialsp + sub #<__STACKSIZE__ + sta lowwater + lda sp+1 + sta initialsp+1 + sbc #>__STACKSIZE__ .if (.cpu .bitand ::CPU_ISET_65SC02) - ina ; Add 256 bytes safety area + ina ; Add 256 bytes safety area .else - add #1 ; Add 256 bytes safety area + add #1 ; Add 256 bytes safety area .endif - sta lowwater+1 - rts + sta lowwater+1 + rts .endproc @@ -55,10 +55,10 @@ .code -stkchk: tsx - cpx #12 - bcc Fail ; Jump on stack overflow - rts ; Return if ok +stkchk: tsx + cpx #12 + bcc Fail ; Jump on stack overflow + rts ; Return if ok ; ---------------------------------------------------------------------------- ; C stack checking routine. Does not need to save any registers. @@ -69,34 +69,34 @@ cstkchk: ; Check the high byte of the software stack -@L0: lda lowwater+1 - cmp sp+1 - bcs @L1 - rts +@L0: lda lowwater+1 + cmp sp+1 + bcs @L1 + rts ; Check low byte -@L1: bne CStackOverflow - lda lowwater - cmp sp - bcs CStackOverflow -Done: rts +@L1: bne CStackOverflow + lda lowwater + cmp sp + bcs CStackOverflow +Done: rts ; We have a C stack overflow. Set the stack pointer to the initial value, so ; we can continue without worrying about stack issues. CStackOverflow: - lda initialsp - sta sp - lda initialsp+1 - sta sp+1 + lda initialsp + sta sp + lda initialsp+1 + sta sp+1 ; Generic abort entry. We should output a diagnostic here, but this is ; difficult, since we're operating at a lower level here. -Fail: lda #4 +Fail: lda #4 ldx #0 - jmp _exit + jmp _exit ; ---------------------------------------------------------------------------- ; Data @@ -105,10 +105,10 @@ Fail: lda #4 ; Initial stack pointer value. Stack is reset to this in case of overflows to ; allow program exit processing. -initialsp: .word 0 +initialsp: .word 0 ; Stack low water mark. -lowwater: .word 0 +lowwater: .word 0