home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pcmagazi / 1989 / 22 / setjmp.pas < prev    next >
Pascal/Delphi Source File  |  1989-11-10  |  1KB  |  43 lines

  1.  
  2. SETJUMP.PAS
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9. {*        Copyright (c) TurboPower Software 1987.        *}
  10. TYPE
  11.   JumpRecord =
  12.     RECORD
  13.       SpReg, BpReg : Word;
  14.       JmpPt : Pointer;
  15.     END;
  16.  
  17.   PROCEDURE SetJump(VAR JumpDest : JumpRecord);
  18.     {-Save current SP, BP, and a jump destination}
  19.   INLINE(
  20.      $5F/               {pop di           ;di = Ofs(JmpDest)}
  21.      $07/               {pop es           ;es = Seg(JmpDest)}
  22.      $26/$89/$25/       {mov es:[di],sp   ;save sp}
  23.      $26/$89/$6D/$02/   {mov es:[di+2],bp ;save bp}
  24.      $E8/$00/$00/       {call null        ;push IP onto stack}
  25.      {null:}
  26.      $58/               {pop ax           ;pop into ax}
  27.      $05/$0C/$00/       {add ax,12        ;point to "next:"}
  28.      $26/$89/$45/$04/   {mov es:[di+4],ax ;save jump offset}
  29.      $26/$8C/$4D/$06);  {mov es:[di+6],cs ;save jump segment}
  30.   {next:}
  31.  
  32.   PROCEDURE LongJump(VAR JumpDest : JumpRecord);
  33.     {-Restore SP, BP, and jump to JumpDest.JmpPt}
  34.   INLINE(
  35.      $5F/               {pop di            ;di = Ofs(JumpDest)}
  36.      $07/               {pop es            ;es = Seg(JumpDest)}
  37.      $26/$8B/$25/       {mov sp,es:[di]    ;restore sp}
  38.      $26/$8B/$6D/$02/   {mov bp,es:[di+2]  ;restore bp}
  39.      $26/$FF/$6D/$04);  {jmp far es:[di+4] ;jump far to JumpDest.JmpPt}
  40.  
  41.  
  42.  
  43.