home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / bp_6_93 / bonus / winer / dosint.asm < prev    next >
Assembly Source File  |  1992-05-12  |  2KB  |  78 lines

  1. ;DOSINT.ASM, "short-cut" routine replaces CALL INTERRUPT
  2.  
  3. ;Copyright (c) 1991 Ethan Winer
  4.  
  5.  
  6. .Model Medium, Basic
  7.  
  8. Registers Struc
  9.   RegAX  DW ?
  10.   RegBX  DW ?
  11.   RegCX  DW ?
  12.   RegDX  DW ?
  13.   RegBP  DW ?
  14.   RegSI  DW ?
  15.   RegDI  DW ?
  16.   Flags  DW ?
  17.   RegDS  DW ?
  18.   RegES  DW ?
  19. Registers Ends
  20.  
  21. .Code
  22.  
  23. DOSInt Proc Uses SI DI DS, Regs:Word
  24.  
  25.   Mov  SI,Regs            ;get the address of the Registers TYPE or array
  26.  
  27.   Mov  AX,[SI+RegAX]      ;load each register in succession
  28.   Mov  BX,[SI+RegBX]
  29.   Mov  CX,[SI+RegCX]
  30.   Mov  DX,[SI+RegDX]
  31.   Mov  BP,[SI+RegBP]
  32.   Mov  DI,[SI+RegDI]
  33.   Mov  ES,[SI+RegES]
  34.  
  35.   Push [SI+RegSI]         ;save the incoming SI register for a moment
  36.  
  37.   Cmp  [SI+RegES],-1      ;do they want the default for ES?
  38.   Jne  @F                 ;no, use what we loaded
  39.   Push DS                 ;yes, move DS into ES
  40.   Pop  ES
  41.  
  42. @@:
  43.   Cmp  [SI+RegDS],-1      ;do they want the default for DS?
  44.   Je   @F                 ;yes, leave DS alone
  45.   Mov  DS,[SI+RegDS]      ;no, assign DS from the incoming table
  46.  
  47. @@:
  48.   Pop  SI                 ;finally, retrieve SI
  49.   Int  21h                ;and call DOS
  50.  
  51.   Push BP                 ;save BP and then setup access to the stack
  52.   Mov  BP,SP
  53.   Push DS                 ;save these too because we need them to
  54.   Push SI                 ;address the table
  55.  
  56.   Mov  DS,[BP+2]          ;reload DS from where it was originally stored
  57.   Mov  SI,[BP+0EH]        ;and SI too
  58.  
  59.   Mov  [SI+RegAX],AX      ;now assign the values back to the caller
  60.   Mov  [SI+RegBX],BX
  61.   Mov  [SI+RegCX],CX
  62.   Mov  [SI+RegDX],DX
  63.  
  64.   Pop  [SI+RegSI]
  65.   Pop  [SI+RegDS]
  66.   Pop  [SI+RegBP]
  67.  
  68.   Mov  [SI+RegDI],DI
  69.   Mov  [SI+RegES],ES
  70.  
  71.   Pushf
  72.   Pop  [SI+Flags]
  73.  
  74.   Ret
  75.  
  76. DOSInt Endp
  77. End
  78.