home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / dskutl / reform16.arc / REFORMAT.IN2 < prev    next >
Text File  |  1987-05-22  |  3KB  |  59 lines

  1. (*
  2.  REFORMAT.IN2
  3.  Inline code for Int25 and Int26 procedures, replaces the original
  4.  INT25.ASM and INT26.ASM.
  5.  Author David Kirschbaum (ABN.ISCAMS@USC-ISID) May 86.
  6.  REFORMAT.PAS author Jos Wennmacker (URC) apr '86.
  7.  
  8.  Since we only use one Register record variable, AND it's a global one,
  9.  I stripped out passing its address as a parameter and just rely on it
  10.  being in the DS data segment.
  11. *)
  12.  
  13. PROCEDURE Int2526(R : Byte);
  14. {
  15.   Uses global variable Register.  Pass $25 (read) or $26 (write)
  16.   as R for the function you desire.
  17. }
  18.   BEGIN
  19.   InLine(
  20.   $1E             { push ds              ;save what we are about to clobber }
  21.   /$BE/>Register  { mov  si,>Register    ;load DS:Regs (global) address }
  22.   /$8A/$04        { mov  al,byte ptr[si] ;Regs.al }
  23.   /$8B/$5C/$02    { mov  bx,[si+2]       ;Regs.bx }
  24.   /$8B/$4C/$04    { mov  cx,[si+4]       ;Regs.cx }
  25.   /$8B/$54/$06    { mov  dx,[si+6]       ;Regs.dx }
  26.   /$56            { push SI              ;save Regs addr }
  27.   /$8B/$74/$0E    { mov  si,[si+14]      ;Regs.DS }
  28.   /$8E/$DE        { mov  ds,si           ;DS=Regs.DS }
  29.   /$55            { push bp              ;DOS destroys it }
  30.   /$FC            { cld                  ;if you don't, DOS 2 makes a mess! }
  31.   /$80/$BE/>R/$25 { cmp  byte ptr >R[BP],$25     ;doing a read? }
  32.   /$75/$05        { jne  Do26            ;nope }
  33.   /$CD/$25        { int  $25             ;yep, do the read }
  34.   /$E9/$02/$00    { jmp  Done            ;and skip }
  35.                   { Do26: }
  36.   /$CD/$26        { int  $26             ;do the write }
  37.                   { Done:                ;old flags are still on the stack! }
  38.   /$5F            { pop  DI              ;so save them here a sec }
  39.   /$5D            { pop  BP }
  40.   /$5E            { pop  SI              ;Regs addr }
  41.   /$1F            { pop  DS              ;Regs seg }
  42.   /$9C            { pushf                ;move the new flags... }
  43.   /$8F/$44/$12    { pop  [si+18]         ;into as Reg.Flags }
  44.   /$89/$04        { mov  [si],ax         ;possible errors }
  45.   /$57            { push DI              ;old flags.. }
  46.                   { ;popf                ;..restored }
  47.                   { ;one way to evade the older 80286's }
  48.                   { ;problem of blowing up during a POPF }
  49.   /$E9/$01/$00    { jmp  J1              ;skip over IRET }
  50.                   { C1: }
  51.   /$CF            { iret                 ;pop IP/CS/Flags }
  52.                   { J1: }
  53.   /$0E            { push CS              ;make a return }
  54.   /$2E            { CS: }
  55.   /$E8/$FA/$FF    { call C1              ;pop the Flags }
  56. );
  57.   { BX,CX,DX should not have changed, so no need to post Regs. }
  58.   END;   { of Int2526 }
  59.