home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / lib / mntc6846.zoo / patch / stackche.s < prev    next >
Encoding:
Text File  |  1994-10-17  |  1017 b   |  41 lines

  1. *
  2. * Stack check routine.
  3. *
  4. * Called from C68 if the -stackcheck runtime option is selected.
  5. *
  6. * Export: .stackcheck
  7. *
  8.     .text
  9.     .globl    .stackcheck
  10.  
  11. .stackcheck:
  12.     move.l    sp,d0        ; get stack pointer value
  13.     addq.l    #8,d0        ; don't count our own stack usage
  14.     move.l    d0,__act_sp
  15.     move.l    __spbase,d1
  16.     sub.l    d0,d1
  17.     add.l    4(sp),d1
  18.     cmp.l    __stksize,d1
  19.     bpl    err
  20.     cmp.l    __stackmax,d1
  21.     bpl    max
  22. *
  23. *   The exit code.  In the case of a dummy version of this
  24. *   routine, this is all that is needed.
  25. *
  26. fin:    move.l    (sp)+,a0    ; get return address
  27.     addq.l    #4,sp        ; tidy stack by removing parameters
  28.     jmp    (a0)        ; return to calling point
  29. *
  30. *   This routine can do whatever it likes.  Typically this 
  31. *   would be to update statistics on stack useage.
  32. *
  33. max:    move.l  d1,__stackmax    ; store new maximum
  34.     jsr    __stack_newmax    ; call routine when new max reached
  35.     bra    fin
  36. *
  37. *   We expect that routine we call here to abort the program !
  38. *
  39. err:    move.l    _abort,(sp)    ; set abort routine as return address
  40.     jmp    __stack_error    ; call error reporting routine
  41.