home *** CD-ROM | disk | FTP | other *** search
- page 58,132
-
- ; sysint.asm
- ; contains: sysint()
- ;
- include model.h
- include prologue.h
- include equ.h
- name sysint
- pseg sysint
-
- ;==>-- int sysint(intno,regin,regout)
- ;
- ;; ARGUMENTS:
- ; (int) intno - software interrupt to execute
- ; (struct GFREGS *) regin - registers prior to interrupt
- ; (struct GFREGS *) regout - registers after the interrupt
- ;
- ;; DESCRIPTION:
- ; Load 8086/88/286/386 registers from structure and execute
- ; specified software interrupt. After interrupt store cpu
- ; registers in structure regout.
- ;
- ;; SIDE EFFECTS:
- ; self modifying code
- ;
- ;; RETURNS:
- ; value of flag register following interrupt
- ;
- ;; AUTHOR:
- ; ""
- ; Copyright (C)1987-1990 Greenleaf Software Inc. All Rights Reserved.
- ;;;
- intarg equ @ab ;location of value of interrupt vector
- ptrin equ @ab+2 ;pointer to input struct
-
- if _LDATA
- ptrout equ @ab+6 ;pointer to output struct
- else
- ptrout equ @ab+4 ;if 16 bit pointers
- endif
- cproc sysint
- push es ;and ES
- push ds ;save DS
- if _LDATA
- les si,dword ptr [bp].ptrout
- push es
- push si
- else
- push ds
- push [bp].ptrout
- endif
- mov al,intarg[bp] ;get interrupt number
- mov cs:intnum,al ;store low-byte only.
- cmp al,25h ;now check assumption
- jl no256 ;assumed correct
- cmp al,26h ; also this
- jg no256 ;also assumed correct
- or al,1 ;not zero if 25/26
- jmp short start1
- no256: xor al,al ;set zero flag if not 25/26
- start1:
- if _LDATA ;if long pointer
- lds si,dword ptr ptrin[bp]
- else
- mov si,ptrin[bp] ;get short pointer
- endif
- mov bx,[si+2] ;BX
- mov cx,[si+4] ;CX
- mov dx,[si+6] ;DX
- mov di,[si+10] ;DI
- mov es,[si+14] ;ES
- mov ax,[si+0] ;AX
- push [si+8] ;SI -> stack
- mov ds,[si+12] ;DS
- pop si ;SI
- mov bp,sp
- push bp
- jnz doint ;if interrupt 25/26 skip next push
- push bp ;if not 25/26 push extra
- doint:
- db 0cdh ;interrupt instruction
- intnum equ this byte
- db 0
- pop bp ;if int 25/26 flags, if not push from above
- pop bp ;regardless this is the good one
- push ds ;doesn't xchg well
- xchg si,[bp] ;si = offset of output struct
- xchg ax,[bp+2] ;ax = seg of output struct
- mov ds,ax
- pop [si+12] ;DS
- pop [si+8] ;SI
- pop [si] ;AX
- mov [si+2],bx ;BX
- mov [si+4],cx ;CX
- mov [si+6],dx ;DX
- mov [si+10],di ;DI
- mov [si+14],es ;ES
- pushf ;push flags
- pop ax ;& return in ax
- pop ds
- pop es
- cproce
- endps
- end
-