home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / CLIPB52.ZIP / SPENCE.ZIP / RICKA.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-06-04  |  2.3 KB  |  104 lines

  1.     ; The source code provided herein remains the property of Rick
  2.     ; Spence and Software Design Consultants. You are, however, free to
  3.     ; use it, but please do not republish.
  4.  
  5.  
  6.     ; RICKA.ASM - Rick Spence's Assembler code from the Advanced C
  7.     ;             presentation, 1990 Devcon
  8.     ;
  9.     ; Program 9 - 9 Assembly Language Version of int86
  10.  
  11.     PUBLIC _aint86                 ; Assembly version of int86
  12.  
  13.     _code  SEGMENT BYTE PUBLIC 'CODE'
  14.  
  15.     ASSUME CS:_code
  16.  
  17.     ; _aint86(int int_num, union REGS *in_regs,  union REGS *out_regs)
  18.  
  19.  
  20.     regs_word STRUC
  21.  
  22.         AX_REG    DW 0
  23.         BX_REG    DW 0
  24.         CX_REG    DW 0
  25.         DX_REG    DW 0
  26.         SI_REG    DW 0
  27.         DI_REG    DW 0
  28.         FLAGS_REG DW 0
  29.  
  30.     regs_word ENDS
  31.  
  32.  
  33.     _aint86 PROC FAR
  34.  
  35.         PUSH    BP
  36.         MOV     BP, SP
  37.  
  38.         PUSH    DS
  39.         PUSH    ES
  40.         PUSH    SI    
  41.         PUSH    DI    
  42.  
  43.         ; get int_num
  44.         MOV     AX, WORD PTR [BP + 06]
  45.  
  46.         ; Write over second byte of INT instruction
  47.         MOV     CS: BYTE PTR int_lab + 1, AL
  48.     
  49.         ; Pointer to input registers.
  50.         LDS     SI, DWORD PTR [BP + 08]
  51.  
  52.         ; load in regs
  53.         MOV     AX, [SI.AX_REG]
  54.         MOV     BX, [SI.BX_REG]
  55.         MOV     CX, [SI.CX_REG]
  56.         MOV     DX, [SI.DX_REG]
  57.         MOV     DI, [SI.DI_REG]
  58.         MOV     SI, [SI.SI_REG]     ; This must be last ...
  59.  
  60.         ; Assemble INT 0, overwrite the actual interrupt vector!
  61.  
  62.     int_lab:
  63.         INT     0
  64.  
  65.         PUSHF
  66.  
  67.         ; Save SI so we can use it to point to the out regs
  68.         PUSH    SI
  69.  
  70.         ; out regs
  71.         LDS     SI, DWORD PTR [BP + 0CH]
  72.  
  73.         MOV     [SI.AX_REG], AX
  74.         MOV     [SI.BX_REG], BX
  75.         MOV     [SI.CX_REG], CX
  76.         MOV     [SI.DX_REG], DX
  77.         MOV     [SI.DI_REG], DI
  78.  
  79.         ; GET saved SI into AX so we can save it back
  80.         POP     AX
  81.         MOV     [SI.SI_REG], AX
  82.  
  83.         ; now pop flags we saved off stack
  84.         POP     AX
  85.         MOV     [SI.FLAGS_REG], AX
  86.  
  87.         ; And finally, we return
  88.         POP     DI
  89.         POP     SI
  90.         POP     ES
  91.         POP     DS
  92.  
  93.         POP     BP
  94.         RET    
  95.  
  96.     _aint86 ENDP
  97.  
  98.     _code ENDS
  99.  
  100.     END
  101.  
  102.  
  103.  
  104.