home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / MAILBOX.ZIP / MPVAXSJ.S < prev    next >
Encoding:
Text File  |  1988-06-27  |  2.4 KB  |  69 lines

  1. #****************************************************************************/
  2. #* mpvaxsj.s -- VAX ASSEMBLY FOR C setjmp & longjmp FUNCTIONS               */
  3. #* Created:  11/29/87        Release:  0.7        Version:  12/3/87   */
  4. #****************************************************************************
  5. #(c) Copyright 1987 by Michael Benjamin Parker           (USA SS# 557-49-4130)
  6. #
  7. #All Rights Reserved unless specified in the following include files: */
  8. ##include "mptsk.cpy" /*
  9. #
  10. #DO NOT REMOVE OR ALTER THIS NOTICE AND ITS PROVISIONS.
  11. #****************************************************************************/
  12. #****************************************************************************/
  13. #* OVERVIEW: see mpvaxsj.h
  14. # This is a reimplementation of the standard "C" setjmp and longjmp functions.
  15. #****************************************************************************/
  16. #****************************************************************************/
  17. #
  18.  
  19. # Format for MPVAXSJ:
  20. #    0:    sp (r14)
  21. #    1:    SPA | 1 | 0 | REGISTER MASK <11:0> | PSW <15:5> | 0
  22. #    2:    ap (r12)
  23. #    3:    fp (r13)
  24. #    4:    pc (r15)
  25. #    5:    r1
  26. #    ....
  27. #    15:    r11
  28. #    16:    No of Arguments (assumes "calls" call)
  29. #
  30. # The "setjmp" function pushes all the remaining registers (r1-r11) onto the
  31. # stack frame (see 1111 1111 1110b = FFEh register mask) on entry, then
  32. # copies the entire stack frame (64d bytes or 16 int's) into the MPVAXSJ
  33. # buffer and returns 0.
  34. # Note: BSD 4.2 Vax cc only assumes registers r6-r11 saved across function
  35. #    calls (mask FC0h), but I save them all just in case.
  36.  # ENTRY(mpvaxsj_setjmp, 0xffe)
  37.     .text
  38.     .align 1
  39.     .globl    _mpvaxsj_setjmp
  40. _mpvaxsj_setjmp:
  41.  
  42.     .word 0xffe        # Save all registers r1-r11
  43.     movl    4(ap),    r0    # Get the address of the MPVAXSJ buffer
  44.     movl    fp,    (r0)    # Store the Stack Pointer
  45.     movc3    $64,4(fp),4(r0)    # Store the Stack Frame (except Cond. Codes)
  46.     clrl    r0        # Return 0
  47.     ret
  48.  
  49. # The "longjmp" function returns the argument passed to it using the MPVAXSJ
  50. # buffer (previously set) as the stack frame.
  51.  # ENTRY(mpvaxsj_longjmp, 0)
  52.     .text
  53.     .align 1
  54.     .globl _mpvaxsj_longjmp
  55. _mpvaxsj_longjmp:
  56.  
  57.     .word 0            # Don't save anything (we'll never return)
  58.     movl    8(ap),    r6    # Save Return Value
  59.     movl    4(ap),    r0    # Get the address of the MPVAXSJ buffer
  60.     movl    (r0),    fp    # Restore the old stack pointer
  61.     movc3    $64,4(r0),4(fp)    # Restore the Stack Frame (except Cond. Codes)
  62.     clrl    (fp)        # Clear the Condition Codes
  63.     movl    r6,    r0    # Return the value passed
  64.     ret
  65.  
  66.  
  67.  
  68.  
  69.