home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TOOL_INC.ZIP / LONGJMP.INC < prev    next >
Encoding:
Text File  |  1988-01-29  |  1.1 KB  |  30 lines

  1.  
  2.   TYPE
  3.      JumpRec = array[1..6] of byte;
  4.  
  5.   (* -------------------SetJump------------------------ *)
  6.   PROCEDURE SetJump(VAR Save : JumpRec);
  7.     {save the machine state and the pc for a later jump, longjumps
  8.      will return to where SetJmp was called}
  9.   BEGIN
  10.     InLine($8B/$5E/$04/ {mov bx,[bp+4]  ;get address of jump record}
  11.       $89/$E8/          {mov ax,bp      ;current bp}
  12.       $05/$08/$00/      {add ax,8       ;the sp when call was made}
  13.       $89/$07/          {mov [bx],ax    ;store in spreg}
  14.       $8B/$46/$00/      {mov ax,[bp]    ;caller'S BP}
  15.       $89/$47/$02/      {mov [bx+2],ax  ;store in bpreg}
  16.       $8B/$46/$02/      {mov ax,[bp+2]  ;the return address}
  17.       $89/$47/$04);     {mov [bx+4],ax  ;store in jmpadr}
  18.   END;
  19.  
  20.   (* -------------------LongJump---------------------- *)
  21.   PROCEDURE LongJump(Save : JumpRec);
  22.     {restore the machine state and make the jump}
  23.   BEGIN
  24.     InLine($8B/$5E/$08/ {mov bx,[bp+8]   ;get jump adress}
  25.       $8B/$66/$04/      {mov sp,[bp+4]   ;restore sp}
  26.       $8B/$6E/$06/      {mov bp,[bp+6]   ;and also bp}
  27.       $FF/$E3);         {jmp bx          ;make the long jump}
  28.   END;
  29.  
  30.