home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 December
/
simtel1292_SIMTEL_1292_Walnut_Creek.iso
/
msdos
/
sysutl
/
clock.arc
/
CSYSINT.LST
< prev
next >
Wrap
File List
|
1986-12-20
|
7KB
|
166 lines
The IBM Personal Computer MACRO Assembler 12-20-86 PAGE 1-1
1 PAGE 54,130
2 ; CSYSINT - Lattice "C" interface to the world
3 ;
4 ; This program was adapted from PSYSINT, a program listed
5 ; and described by Will Fastie in SOFTALK Magazine, which
6 ; provided access to system calls from IBM Pascal programs.
7 ; It in turn was taken from George Eberhart's version for the
8 ; Computer Inovations C86 Compiler, with permission.
9 ;
10 ; Modified by T. Cox to match the Microsoft C Compiler
11 ; assembly language interface call conventions, and renamed
12 ; to CSYSINT.
13 ;
14 ; C calling sequence:
15 ;
16 ; flags = csysint(interrupt,&sreg,&rreg);
17 ;
18 ; Where sreg and rreg are structures of four words each representing
19 ; the 8088 registers AX, BX, CX, and DX. "regsetT is a structure
20 ; defining these as all the half-register names (e.g.,AL,AH).
21 ;
22 ; interrupt is the number of the system interrupt desired.
23 ;
24 ; The return value is a 16-bit unsigned integer. It contains
25 ; the machine status register.
26 ;
27 ; This C function calling sequence passes the interrupt code as a value
28 ; and the two register sets as pointers to their respective structures.
29 ;
30 ; The incoming stack looks like this in memory locations "mem". Note
31 ; that the call is a NEAR call (page 1-36 of the Microsoft C manual),
32 ; so only the return address (and not the segment address) is pushed.
33 ;
34 ; High <-- Caller's BP
35 ; mem + 06: interrupt code value
36 ; mem + 04: SREG address
37 ; mem + 02: RREG address
38 ; mem + 00: caller's saved BP
39 ; Low <-- BP, SP
40 ;
41 PGROUP GROUP PROG
42 PARAMS STRUC
43 0000 ???? OLD_BP DW ? ; Caller's BP Save
44 0002 ???? RETN DW ? ; Return address from call
45 0004 ???? ARG1 DW ? ; First arguement
46 0006 ???? ARG2 DW ? ; Second arguement
47 0008 ???? ARG3 DW ? ; Third arguement
48 000A PARAMS ENDS
49 ;
The IBM Personal Computer MACRO Assembler 12-20-86 PAGE 1-2
50 0000 PROG SEGMENT BYTE PUBLIC 'PROG'
51 ASSUME CS:PGROUP
52 PUBLIC CSYSINT
53 ;
54 0000 CSYSINT PROC NEAR
55 0000 55 PUSH BP ; save caller's frame pointer
56 0001 8B EC MOV BP,SP ; set up our frame pointer
57 ;
58 0003 E8 0006 R CALL DUMMY ; trick - push the IP
59 0006 DUMMY:
60 0006 58 POP AX ; get it
61 0007 2D 0006 R SUB AX,OFFSET DUMMY ; calculate the address of the INT
62 000A 05 001A R ADD AX,OFFSET PINT
63 000D 8B F8 MOV DI,AX ; move it to the index register
64 000F 8B 46 04 MOV AX,[BP].ARG1 ; get the desired interrupt number
65 0012 2E: 88 45 01 MOV CS:[DI+1],AL ; put it in the INT instruction
66 0016 E8 0024 R CALL REGSIN ; get the registers from SREG
67 0019 55 PUSH BP ; we'll need our own BP later
68 001A CD 00 PINT: INT 00H ; perform the requested interrupt
69 001C 5D POP BP ; get our BP back
70 001D 9C PUSHF ; hang onto the flags for the return
71 001E E8 0035 R CALL REGSOUT ; put the registers into RREG
72 0021 58 POP AX ; flags are the return value
73 0022 5D POP BP ; restore the caller's frame pointer
74 0023 C3 RET ; return to caller
75 0024 CSYSINT ENDP
76 ;
77 ; ---------------------------------
78 ; Subroutines to move the registers in and out
79 ;
80 = 0004 NRREGS EQU 4 ; this version supports only four regs
81 ;
82 0024 REGSIN PROC NEAR ; -- Move Registers In
83 0024 8B 5E 06 MOV BX,[BP].ARG2 ; get address of register set SREG
84 0027 B9 0004 MOV CX,NRREGS ; ...and how many registers to move
85 002A INLOOP:
86 002A FF 37 PUSH WORD PTR [BX] ; push one
87 002C 43 INC BX ; point to the next one
88 002D 43 INC BX
89 002E E2 FA LOOP INLOOP ; ..do it some more
90 0030 5A POP DX ; now pop them into their proper places
91 0031 59 POP CX
92 0032 5B POP BX
93 0033 58 POP AX
94 0034 C3 RET ; all done
95 0035 REGSIN ENDP
96 ;
97 0035 REGSOUT PROC NEAR ;--Move Registers Out
98 0035 52 PUSH DX ; push all the registers in reverse order
The IBM Personal Computer MACRO Assembler 12-20-86 PAGE 1-3
99 0036 51 PUSH CX
100 0037 53 PUSH BX
101 0038 50 PUSH AX
102 0039 8B 5E 08 MOV BX,[BP].ARG3 ; get the address of RREG
103 003C B9 0004 MOV CX,NRREGS ; ...and how many registers to move
104 003F LOOPOUT:
105 003F 8F 07 POP WORD PTR [BX] ; recover the register
106 0041 43 INC BX ; point to the next
107 0042 43 INC BX
108 0043 E2 FA LOOP LOOPOUT ; do it again
109 0045 C3 RET
110 0046 REGSOUT ENDP
111 ;
112 0046 PROG ENDS
113 END
The IBM Personal Computer MACRO Assembler 12-20-86 PAGE Symbols-1
Structures and records:
N a m e Width # fields
Shift Width Mask Initial
PARAMS . . . . . . . . . . . . . 000A 0005
OLD_BP . . . . . . . . . . . . . 0000
RETN . . . . . . . . . . . . . . 0002
ARG1 . . . . . . . . . . . . . . 0004
ARG2 . . . . . . . . . . . . . . 0006
ARG3 . . . . . . . . . . . . . . 0008
Segments and groups:
N a m e Size align combine class
PGROUP . . . . . . . . . . . . . GROUP
PROG . . . . . . . . . . . . . . 0046 BYTE PUBLIC 'PROG'
Symbols:
N a m e Type Value Attr
CSYSINT. . . . . . . . . . . . . N PROC 0000 PROG Global Length =0024
DUMMY. . . . . . . . . . . . . . L NEAR 0006 PROG
INLOOP . . . . . . . . . . . . . L NEAR 002A PROG
LOOPOUT. . . . . . . . . . . . . L NEAR 003F PROG
NRREGS . . . . . . . . . . . . . Number 0004
PINT . . . . . . . . . . . . . . L NEAR 001A PROG
REGSIN . . . . . . . . . . . . . N PROC 0024 PROG Length =0011
REGSOUT. . . . . . . . . . . . . N PROC 0035 PROG Length =0011
Warning Severe
Errors Errors
0 0