home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / GRLF-C-2.ZIP / GFUNC / SYSINT.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-05-30  |  2.4 KB  |  106 lines

  1.         page    58,132
  2.  
  3. ; sysint.asm
  4. ; contains: sysint()
  5. ;
  6.         include    model.h
  7.         include    prologue.h
  8.         include    equ.h
  9.         name    sysint
  10.         pseg    sysint
  11.  
  12. ;==>--    int sysint(intno,regin,regout)
  13. ;
  14. ;;    ARGUMENTS:
  15. ;      (int)    intno    -    software interrupt to execute
  16. ;      (struct GFREGS *) regin  -    registers prior to interrupt
  17. ;      (struct GFREGS *) regout -    registers after the interrupt
  18. ;
  19. ;;    DESCRIPTION:
  20. ;      Load 8086/88/286/386 registers from structure and execute
  21. ;      specified software interrupt.  After interrupt store cpu
  22. ;      registers in structure regout.
  23. ;
  24. ;;    SIDE EFFECTS:
  25. ;      self modifying code
  26. ;
  27. ;;    RETURNS:
  28. ;      value of flag register following interrupt
  29. ;
  30. ;;    AUTHOR:
  31. ;     ""
  32. ;      Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
  33. ;;;
  34. intarg    equ    @ab        ;location of value of interrupt vector
  35. ptrin    equ    @ab+2        ;pointer to input struct
  36.  
  37.     if    _LDATA
  38. ptrout    equ    @ab+6        ;pointer to output struct
  39.      else
  40. ptrout    equ    @ab+4        ;if 16 bit pointers
  41.      endif
  42.     cproc    sysint
  43.     push    es        ;and ES
  44.     push    ds        ;save DS
  45.     if    _LDATA
  46.      les    si,dword ptr [bp].ptrout
  47.      push    es
  48.      push    si
  49.     else
  50.      push    ds
  51.      push    [bp].ptrout
  52.     endif
  53.     mov    al,intarg[bp]    ;get interrupt number
  54.     mov    cs:intnum,al    ;store low-byte only.
  55.     cmp    al,25h        ;now check assumption
  56.     jl    no256        ;assumed correct
  57.     cmp    al,26h        ; also this
  58.     jg    no256        ;also assumed correct
  59.     or    al,1        ;not zero if 25/26
  60.     jmp    short start1
  61. no256:    xor    al,al        ;set zero flag if not 25/26
  62. start1:
  63.     if    _LDATA            ;if long pointer
  64.      lds    si,dword ptr ptrin[bp]
  65.     else
  66.      mov    si,ptrin[bp]    ;get short pointer
  67.     endif
  68.     mov    bx,[si+2]    ;BX
  69.     mov    cx,[si+4]    ;CX
  70.     mov    dx,[si+6]    ;DX
  71.     mov    di,[si+10]    ;DI
  72.     mov    es,[si+14]    ;ES
  73.     mov    ax,[si+0]    ;AX
  74.     push    [si+8]        ;SI -> stack
  75.     mov    ds,[si+12]    ;DS
  76.     pop    si        ;SI
  77.     mov    bp,sp
  78.     push    bp
  79.     jnz    doint        ;if interrupt 25/26 skip next push
  80.     push    bp        ;if not 25/26 push extra
  81. doint:    
  82.     db    0cdh        ;interrupt instruction
  83. intnum equ this byte
  84.     db    0
  85.     pop    bp        ;if int 25/26 flags, if not push from above
  86.     pop    bp        ;regardless this is the good one
  87.     push    ds        ;doesn't xchg well
  88.     xchg    si,[bp]        ;si = offset of output struct
  89.     xchg    ax,[bp+2]    ;ax = seg of output struct
  90.     mov    ds,ax
  91.     pop    [si+12]        ;DS
  92.     pop    [si+8]        ;SI
  93.     pop    [si]        ;AX
  94.     mov    [si+2],bx    ;BX
  95.     mov    [si+4],cx    ;CX
  96.     mov    [si+6],dx    ;DX
  97.     mov    [si+10],di    ;DI
  98.     mov    [si+14],es    ;ES
  99.     pushf            ;push flags
  100.     pop    ax        ;& return in ax
  101.     pop    ds
  102.     pop    es
  103.     cproce
  104.     endps
  105.     end
  106.