home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / gnuc / gen_library / rcs / _setjmp.s,v next >
Encoding:
Text File  |  1992-07-04  |  2.6 KB  |  98 lines

  1. head    1.1;
  2. access;
  3. symbols
  4.     version39-41:1.1;
  5. locks;
  6. comment    @# @;
  7.  
  8.  
  9. 1.1
  10. date    92.06.08.18.31.20;    author mwild;    state Exp;
  11. branches;
  12. next    ;
  13.  
  14.  
  15. desc
  16. @initial checkin
  17. @
  18.  
  19.  
  20. 1.1
  21. log
  22. @Initial revision
  23. @
  24. text
  25. @/*-
  26.  * Copyright (c) 1990 The Regents of the University of California.
  27.  * All rights reserved.
  28.  *
  29.  * This code is derived from software contributed to Berkeley by
  30.  * the Systems Programming Group of the University of Utah Computer
  31.  * Science Department.
  32.  *
  33.  * Redistribution and use in source and binary forms are permitted
  34.  * provided that: (1) source distributions retain this entire copyright
  35.  * notice and comment, and (2) distributions including binaries display
  36.  * the following acknowledgement:  ``This product includes software
  37.  * developed by the University of California, Berkeley and its contributors''
  38.  * in the documentation or other materials provided with the distribution
  39.  * and in all advertising materials mentioning features or use of this
  40.  * software. Neither the name of the University nor the names of its
  41.  * contributors may be used to endorse or promote products derived
  42.  * from this software without specific prior written permission.
  43.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  44.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  45.  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  46.  */
  47.  
  48. #if defined(LIBC_SCCS) && !defined(lint)
  49.     .asciz "@@(#)_setjmp.s    5.1 (Berkeley) 5/12/90"
  50. #endif /* LIBC_SCCS and not lint */
  51.  
  52. /*
  53.  * C library -- _setjmp, _longjmp
  54.  *
  55.  *    _longjmp(a,v)
  56.  * will generate a "return(v)" from
  57.  * the last call to
  58.  *    _setjmp(a)
  59.  * by restoring registers from the stack,
  60.  * The previous signal state is NOT restored.
  61.  */
  62.  
  63. #include "DEFS.h"
  64.  
  65. ENTRY(_setjmp)
  66.     movl    sp@@(4),a0    /* save area pointer */
  67.     clrl    a0@@+        /* no old onstack */
  68.     clrl    a0@@+        /* no old sigmask */
  69.     movl    sp,a0@@+        /* save old SP */
  70.     movl    a5,a0@@+        /* save old FP */
  71.     clrl    a0@@+        /* no old AP */
  72.     movl    sp@@,a0@@+    /* save old PC */
  73.     clrl    a0@@+        /* clear PS */
  74.     moveml    d2-d7/a2-a4/a6,a0@@    /* save other non-scratch regs */
  75.     clrl    d0        /* return zero */
  76.     rts
  77.  
  78. ENTRY(_longjmp)
  79.     movl    sp@@(4),a0    /* save area pointer */
  80.     addql    #8,a0        /* skip onstack/sigmask */
  81.     tstl    a0@@        /* ensure non-zero SP */
  82.     jeq    botch        /* oops! */
  83.     movl    sp@@(8),d0    /* grab return value */
  84.     jne    ok        /* non-zero ok */
  85.     moveq    #1,d0        /* else make non-zero */
  86. ok:
  87.     movl    a0@@+,sp        /* restore SP */
  88.     movl    a0@@+,a5        /* restore FP */
  89.     addql    #4,a0        /* skip AP */
  90.     movl    a0@@+,sp@@    /* restore PC */
  91.     moveml    a0@@(4),d2-d7/a2-a4/a6    /* restore non-scratch regs */
  92.     rts
  93.  
  94. botch:
  95.     jsr    _longjmperror
  96.     stop    #0
  97. @
  98.