home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / archives / packetdrivers.tar.gz / pd.tar / src / popf.asm < prev    next >
Assembly Source File  |  1995-06-25  |  761b  |  40 lines

  1. ;put into the public domain by Russell Nelson, nelson@crynwr.com
  2.  
  3.     extrn    is_286: byte
  4.  
  5.     public    fix_popf
  6. fix_popf:
  7.     cmp    is_286,0        ;is this a 286?
  8.     je    fix_popf_not
  9.  
  10.     push    bp
  11.     mov    bp,sp
  12.     push    bx
  13.     mov    bx,2[bp]        ;get their IP.
  14.     add    word ptr [bx-2],(offset popf_subr) - (offset fix_popf)
  15.     pop    bx
  16.     pop    bp
  17. popf_subr:
  18.     iret
  19.  
  20.  
  21. fix_popf_not:
  22. ;it's not a 286, back-patch our code so that it just does the popf.
  23.     push    bp
  24.     mov    bp,sp
  25.     push    bx
  26.     mov    bx,2[bp]        ;get their IP.
  27.     mov    word ptr [bx-4],9dh + 90h*256    ;popf,nop,nop,nop
  28.     mov    word ptr [bx-2],90h + 90h*256
  29.     pop    bx
  30.     pop    bp
  31.     iret
  32.  
  33. ;On early 286 processors POPF will momentarily enable interrupts even if
  34. ;interrupts are currently disabled, and the popped flags still disable them.
  35. popf    macro
  36.     push    cs
  37.     call    fix_popf
  38.     endm
  39.  
  40.