entry.lst
来自「DOS SOURCE CODE,DOS-C started in 1988 as」· LST 代码 · 共 582 行 · 第 1/2 页
LST
582 行
Turbo Assembler Version 3.1 04/11/13 12:54:48 Page 1
entry.ASM
1 ;
2 ; File:
3 ; entry.asm
4 ; Description:
5 ; System call entry code
6 ;
7 ; Copyright (c) 1998
8 ; Pasquale J. Villani
9 ; All Rights Reserved
10 ;
11 ; This file is part of DOS-C.
12 ;
13 ; DOS-C is free software; you can redistribute it and/or
14 ; modify it under the terms of the GNU General public License
15 ; as published by the Free Software Foundation; either version
16 ; 2, or (at your option) any later version.
17 ;
18 ; DOS-C is distributed in the hope that it will be useful, but
19 ; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
21 ; the GNU General public License for more details.
22 ;
23 ; You should have received a copy of the GNU General public
24 ; License along with DOS-C; see the file COPYING. If not,
25 ; write to the Free Software Foundation, 675 Mass Ave,
26 ; Cambridge, MA 02139, USA.
27 ;
28 ; $Header: C:/dos-c/src/kernel/entry.asv 1.0 07 Feb 1998 20:42:08 patv $
29 ;
30 ; $Log: C:/dos-c/src/kernel/entry.asv $
31 ;
32 ; Rev 1.0 07 Feb 1998 20:42:08 patv
33 ; Modified stack fram to match DOS standard
34 ; $EndLog$
35
36
37 0000 _TEXT segment byte public 'CODE'
38 DGROUP group _FIXED_DATA,_DATA,_BSS,_BSSEND ; small model
39 assume cs:_TEXT,ds:DGROUP,ss:DGROUP
40 0000 _TEXT ends
41
42 0000 _FIXED_DATA segment para public 'DATA'
43 0000 _FIXED_DATA ends
44
45 0000 _DATA segment word public 'DATA'
46 0000 _DATA ends
47
48 0000 _BSS segment word public 'BSS'
49 0000 _BSS ends
50
51 0000 _BSSEND segment byte public 'STACK'
52 0000 _BSSEND ends
53
54
55 include stacks.inc
Turbo Assembler Version 3.1 04/11/13 12:54:48 Page 2
entry.ASM
1 56 ;
1 57 ; File:
1 58 ; stacks.inc
1 59 ; Description:
1 60 ; Macro support for register stack frame
1 61 ;
1 62 ; Copyright (c) 1998
1 63 ; Pasquale J. Villani
1 64 ; All Rights Reserved
1 65 ;
1 66 ; This file is part of DOS-C.
1 67 ;
1 68 ; DOS-C is free software; you can redistribute it and/or
1 69 ; modify it under the terms of the GNU General Public License
1 70 ; as published by the Free Software Foundation; either version
1 71 ; 2, or (at your option) any later version.
1 72 ;
1 73 ; DOS-C is distributed in the hope that it will be useful, but
1 74 ; WITHOUT ANY WARRANTY; without even the implied warranty of
1 75 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
1 76 ; the GNU General Public License for more details.
1 77 ;
1 78 ; You should have received a copy of the GNU General Public
1 79 ; License along with DOS-C; see the file COPYING. If not,
1 80 ; write to the Free Software Foundation, 675 Mass Ave,
1 81 ; Cambridge, MA 02139, USA.
1 82 ;
1 83 ; $Logfile: C:/dos-c/hdr/stacks.inv $
1 84 ;
1 85 ; $Header: C:/dos-c/hdr/stacks.inv 1.0 07 Feb 1998 20:59:16 patv $
1 86 ;
1 87 ; $Log: C:/dos-c/hdr/stacks.inv $
1 88 ;
1 89 ; Rev 1.0 07 Feb 1998 20:59:16 patv
1 90 ;Modified stack frame to match DOS standard
1 91 ; $EndLog$
1 92
1 93
1 94 ;
1 95 ; Standard stack frame used throughout DOS-C
1 96 ;
1 97 ; MS-DOS specific
1 98 ;
1 99 ; +---------------+
1 100 ; | irp hi | 26
1 101 ; +---------------+
1 102 ; | irp low | 24
1 103 ; +---------------+
1 104 ; | flags | 22
1 105 ; +---------------+
1 106 ; | cs | 20
1 107 ; +---------------+
1 108 ; | ip | 18
1 109 ; +---------------+
1 110 ; | es | 16
Turbo Assembler Version 3.1 04/11/13 12:54:48 Page 3
entry.ASM
1 111 ; +---------------+
1 112 ; | ds | 14
1 113 ; +---------------+
1 114 ; | bp | 12
1 115 ; +---------------+
1 116 ; | di | 10
1 117 ; +---------------+
1 118 ; | si | 8
1 119 ; +---------------+
1 120 ; | dx | 6
1 121 ; +---------------+
1 122 ; | cx | 4
1 123 ; +---------------+
1 124 ; | bx | 2
1 125 ; +---------------+
1 126 ; | ax | 0
1 127 ; +---------------+
1 128 ;
1 129
1 130 *000 RegFrame struc
1 131 *000 01*(0000) reg_ax dw (?)
1 132 *002 01*(0000) reg_bx dw (?)
1 133 *004 01*(0000) reg_cx dw (?)
1 134 *006 01*(0000) reg_dx dw (?)
1 135 *008 01*(0000) reg_si dw (?)
1 136 *00A 01*(0000) reg_di dw (?)
1 137 *00C 01*(0000) reg_bp dw (?)
1 138 *00E 01*(0000) reg_ds dw (?)
1 139 *010 01*(0000) reg_es dw (?)
1 140 *012 01*(0000) reg_ip dw (?)
1 141 *014 01*(0000) reg_cs dw (?)
1 142 *016 01*(0000) reg_flags dw (?)
1 143 *018 01*(0000) irp_low dw (?)
1 144 *01A 01*(0000) irp_hi dw (?)
1 145 *01C ends
1 146
1 147
1 148 PUSH$ALL macro
1 149 push es
1 150 push ds
1 151 push bp
1 152 push di
1 153 push si
1 154 push dx
1 155 push cx
1 156 push bx
1 157 push ax
1 158 endm
1 159
1 160 POP$ALL macro
1 161 pop ax
1 162 pop bx
1 163 pop cx
1 164 pop dx
1 165 pop si
Turbo Assembler Version 3.1 04/11/13 12:54:48 Page 4
entry.ASM
1 166 pop di
1 167 pop bp
1 168 pop ds
1 169 pop es
1 170 endm
1 171
1 172
173
174 0000 _TEXT segment byte public 'CODE'
175 extrn _int21_syscall:near
176 extrn _int25_handler:NEAR, _int26_handler:NEAR
177 extrn _set_stack:FAR
178 extrn _restore_stack:FAR
179 extrn _api_sp:WORD
180 extrn _api_ss:WORD
181 extrn _disk_api_tos:WORD
182 public _cpm_entry
183 public _int20_handler
184 public _int21_handler
185 public _low_int25_handler
186 public _low_int26_handler
187 public _int27_handler
188
189
190 ;
191 ; MS-DOS CP/M style entry point
192 ;
193 ; VOID FAR
194 ; cpm_entry(iregs UserRegs)
195 ;
196 ; This one is a strange one. The call is to psp:0005h but it returns to the
197 ; function after the call. What we do is convert it to a normal call and
198 ; fudge the stack to look like an int 21h call.
199 ;
200 assume cs:_TEXT
201 0000 _cpm_entry proc far
202 ; Stack is:
203 ; return offset
204 ; psp seg
205 ; 000ah
206 ;
207 0000 55 push bp ; trash old return address
208 0001 8B EC mov bp,sp
209 0003 87 6E 02 xchg bp,2[bp]
210 0006 5D pop bp
211 0007 9C pushf ; start setting up int 21h stack
212 ;
213 ; now stack is
214 ; return offset
215 ; psp seg
216 ; flags
217 ;
218 0008 55 push bp
219 0009 8B EC mov bp,sp ; set up reference frame
220 ;
Turbo Assembler Version 3.1 04/11/13 12:54:48 Page 5
entry.ASM
221 ; reference frame stack is
222 ; return offset bp + 6
223 ; psp seg bp + 4
224 ; flags bp + 2
225 ; bp <--- bp
226 ;
227 000B 50 push ax
228 000C 8B 46 02 mov ax,2[bp] ; get the flags
229 000F 87 46 06 xchg ax,6[bp] ; swap with return address
230 0012 89 46 02 mov 2[bp],ax
231 0015 58 pop ax ; restore working registers
232 0016 5D pop bp
233 ;
234 ; Done. Stack is
235 ; flags
236 ; psp seg (alias .COM cs)
237 ; return offset
238 ;
239 0017 80 F9 24 cmp cl,024h
240 001A 76 04 jbe cpm_error
241 001C 8A E1 mov ah,cl ; get the call # from cl to ah
242 001E EB 05 jmp short _int21_handler ; do the system call
243 0020 B0 00 cpm_error: mov al,0
244 0022 CF iret
245 0023 _cpm_entry endp
246
247
248 ;
249 ; Terminate the current process
250 ;
251 ; VOID INRPT far
252 ; int20_handler(iregs UserRegs)
253 ;
254 assume cs:_TEXT
255 0023 _int20_handler proc far
256 0023 B4 00 mov ah,0 ; terminate through int 21h
257 0025 _int20_handler endp
258
259
260 ;
261 ; MS-DOS system call entry point
262 ;
263 ; VOID INRPT far
264 ; int21_handler(iregs UserRegs)
265 ;
266 assume cs:_TEXT
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?