home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / mint / mntlib24 / setjmp.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-03  |  933 b   |  46 lines

  1. |
  2. | setjmp.cpp 
  3. |
  4.     .text
  5.     .even
  6.     .globl _setjmp
  7. _setjmp:
  8.     movel    sp@(4),a0        | address of jmp_buf[]
  9.     movel    sp@,a0@            | save return address
  10.     moveml    d2-d7/a2-a7,a0@(4)    | save registers d2-d7/a2-a7
  11.     clrl    d0            | return value is 0
  12.     rts
  13.  
  14.     .globl _longjmp
  15.     .globl ___mint
  16.  
  17. #ifdef __MBASE__
  18. #define Mint    __MBASE__@(___mint)
  19. #else
  20. #define Mint    ___mint
  21. #endif
  22.  
  23. _longjmp:
  24. #ifdef __MSHORT__
  25.     tstw    Mint            | see if MiNT is active
  26. #else
  27.     tstl    Mint
  28. #endif
  29.     beq    NOMINT            | no -- do not call sigreturn
  30.     movew    #0x11a, sp@-        | Psigreturn() system call
  31.     trap    #1            | (ignored if not in a sig handler)
  32.     addqw    #2, sp
  33. NOMINT:
  34.     movel    sp@(4),a0        | address of jmp_buf[]
  35. #ifdef __MSHORT__
  36.     movew    sp@(8),d0        | value to return
  37. #else
  38.     movel    sp@(8),d0        | value to return
  39. #endif
  40.     bne    L1            | may not be 0
  41.     movl    #1, d0
  42. L1:
  43.     moveml    a0@(4),d2-d7/a2-a7    | restore saved reggies
  44.     movl    a0@,sp@            | and the saved return address
  45.     rts
  46.