home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / gnu / djgpp / libsrc / c / sys / longjmp.s < prev    next >
Encoding:
Text File  |  1993-07-25  |  1.3 KB  |  54 lines

  1. /* This is file LONGJMP.S */
  2. /*
  3. ** Copyright (C) 1993 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  4. **
  5. ** This file is distributed under the terms listed in the document
  6. ** "copying.dj", available from DJ Delorie at the address above.
  7. ** A copy of "copying.dj" should accompany this file; if not, a copy
  8. ** should be available from where this file was obtained.  This file
  9. ** may not be distributed without a verbatim copy of "copying.dj".
  10. **
  11. ** This file is distributed WITHOUT ANY WARRANTY; without even the implied
  12. ** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. */
  14.  
  15. /*
  16. **    jmp_buf:
  17. **     eax ebx ecx edx esi edi ebp esp eip es fs gs ss
  18. **     0   4   8   12  16  20  24  28  32  36 38 40 42
  19. */
  20.  
  21.     .globl    _longjmp /* jmp_buf, int */
  22. _longjmp:
  23.     pushl    %ebp
  24.     movl    %esp,%ebp
  25.  
  26.     movl    8(%ebp),%edi    /* get jmp_buf */
  27.     movl    12(%ebp),%eax    /* store retval in j->eax */
  28.     movl    %eax,0(%edi)
  29.  
  30.     movl    24(%edi),%ebp
  31.  
  32.     cli
  33.     movw    42(%edi),%ax
  34.     movw    %ax,%ss
  35.     movl    28(%edi),%esp
  36.     
  37.     pushl    32(%edi)    /* for a ret! */
  38.  
  39.     movw    36(%edi),%ax
  40.     movw    %ax,%es
  41.     movw    38(%edi),%ax
  42.     movw    %ax,%fs
  43.     movw    40(%edi),%ax
  44.     movw    %ax,%gs
  45.     movl    0(%edi),%eax
  46.     movl    4(%edi),%ebx
  47.     movl    8(%edi),%ecx
  48.     movl    12(%edi),%edx
  49.     movl    16(%edi),%esi
  50.     movl    20(%edi),%edi
  51.     sti
  52.  
  53.     ret            /* actually jump to new eip */
  54.