apisupt.lst
来自「DOS SOURCE CODE,DOS-C started in 1988 as」· LST 代码 · 共 221 行
LST
221 行
Turbo Assembler Version 3.1 04/11/13 12:54:49 Page 1
APISUPT.ASM
1 ; File:
2 ; apisupt.asm
3 ; Description:
4 ; Assembly support routines for stack manipulation, etc.
5 ;
6 ; Copyright (c) 1995
7 ; Pasquale J. Villani
8 ; All Rights Reserved
9 ;
10 ; This file is part of DOS-C.
11 ;
12 ; DOS-C is free software; you can redistribute it and/or
13 ; modify it under the terms of the GNU General Public License
14 ; as published by the Free Software Foundation; either version
15 ; 2, or (at your option) any later version.
16 ;
17 ; DOS-C is distributed in the hope that it will be useful, but
18 ; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
20 ; the GNU General Public License for more details.
21 ;
22 ; You should have received a copy of the GNU General Public
23 ; License along with DOS-C; see the file COPYING. If not,
24 ; write to the Free Software Foundation, 675 Mass Ave,
25 ; Cambridge, MA 02139, USA.
26 ;
27 ; $Logfile: C:/dos-c/src/kernel/apisupt.asv $
28 ;
29 ; $Header: C:/dos-c/src/kernel/apisupt.asv 1.3 16 Jan 1997 12:46:44 patv $
30 ;
31 ; $Log: C:/dos-c/src/kernel/apisupt.asv $
32 ;
33 ; Rev 1.3 16 Jan 1997 12:46:44 patv
34 ;pre-Release 0.92 feature additions
35 ;
36 ; Rev 1.2 29 May 1996 21:03:38 patv
37 ;bug fixes for v0.91a
38 ;
39 ; Rev 1.1 01 Sep 1995 17:54:26 patv
40 ;First GPL release.
41 ;
42 ; Rev 1.0 02 Jul 1995 9:04:50 patv
43 ;Initial revision.
44 ;
45
46
47 0000 _TEXT segment byte public 'CODE'
48 DGROUP group _DATA,_BSS,_BSSEND ; small model
49 assume cs:_TEXT,ds:DGROUP,ss:DGROUP
50 0000 _TEXT ends
51
52 0000 _DATA segment word public 'DATA'
53 0000 _DATA ends
54
55 0000 _BSS segment word public 'BSS'
Turbo Assembler Version 3.1 04/11/13 12:54:49 Page 2
APISUPT.ASM
56 0000 _BSS ends
57
58 0000 _BSSEND segment byte public 'STACK'
59 0000 _BSSEND ends
60
61
62 extrn _api_sp:word ; api stacks - for context
63 extrn _api_ss:word ; switching
64 extrn _usr_sp:word ; user stacks
65 extrn _usr_ss:word
66
67 0000 _TEXT segment
68 assume cs: _TEXT
69 public _set_stack
70 ;
71 ; void far set_stack(void) -
72 ; save current stack and setup our local stack
73 ;
74 0000 _set_stack proc far
75
76 ; save foreground stack
77
78 ; we need to get the return values from the stack
79 ; since the current stack will change
80 0000 58 pop ax ;get return offset
81 0001 5B pop bx ;get return segment
82
83 ; Save the flags so that we can restore correct interrupt
84 ; state later. We need to disable interrupts so that we
85 ; don't trash memory with new sp-old ss combination
86 0002 9C pushf
87 0003 5A pop dx
88 0004 FA cli
89
90 ; save bp
91 0005 55 push bp
92
93 0006 8B CC mov cx, sp
94 0008 F7 D9 neg cx
95
96 ; save away foreground process' stack
97 000A FF 36 0000e push word ptr DGROUP:_usr_ss
98 000E FF 36 0000e push word ptr DGROUP:_usr_sp
99
100 0012 8C 16 0000e mov word ptr DGROUP:_usr_ss,ss
101 0016 89 26 0000e mov word ptr DGROUP:_usr_sp,sp
102
103 ; setup our local stack
104 001A 8E 16 0000e mov ss,word ptr DGROUP:_api_ss
105 001E 8B 26 0000e mov sp,word ptr DGROUP:_api_sp
106
107 0022 03 CC add cx, sp
108 0024 03 E9 add bp, cx
109
110 ; setup for ret
Turbo Assembler Version 3.1 04/11/13 12:54:49 Page 3
APISUPT.ASM
111 0026 53 push bx
112 0027 50 push ax
113
114 ; now restore interrupt state
115 0028 52 push dx
116 0029 9D popf
117
118 002A CB ret
119
120 002B _set_stack endp
121
122 ;
123 ; void far restore_stack(void) -
124 ; restore foreground stack, throw ours away
125 ;
126 public _restore_stack
127 002B _restore_stack proc far
128
129 ; we need to get the return values from the stack
130 ; since the current stack will change
131 002B 59 pop cx ;get return offset
132 002C 5B pop bx ;get return segment
133
134 ; Save the flags so that we can restore correct interrupt
135 ; state later. We need to disable interrupts so that we
136 ; don't trash memory with new sp-old ss combination
137 002D 9C pushf
138 002E 5A pop dx
139 002F FA cli
140
141 ; save background stack
142 0030 8C 16 0000e mov word ptr DGROUP:_api_ss,ss
143 0034 89 26 0000e mov word ptr DGROUP:_api_sp,sp
144
145 ; restore foreground stack here
146 0038 8E 16 0000e mov ss,word ptr DGROUP:_usr_ss
147 003C 8B 26 0000e mov sp,word ptr DGROUP:_usr_sp
148
149 0040 8F 06 0000e pop word ptr DGROUP:_usr_sp
150 0044 8F 06 0000e pop word ptr DGROUP:_usr_ss
151
152 ; make bp relative to our stack frame
153 0048 5D pop bp
154 ;mov bp,sp
155
156 ; setup for ret
157 0049 53 push bx
158 004A 51 push cx
159
160 ; now restore interrupt state
161 004B 52 push dx
162 004C 9D popf
163
164 004D CB ret
165 004E _restore_stack endp
Turbo Assembler Version 3.1 04/11/13 12:54:49 Page 4
APISUPT.ASM
166
167 004E _TEXT ends
168
169 end
Turbo Assembler Version 3.1 04/11/13 12:54:49 Page 5
Symbol Table
Symbol Name Type Value
??DATE Text "04/11/13"
??FILENAME Text "APISUPT "
??TIME Text "12:54:49"
??VERSION Number 030A
@CPU Text 0101H
@CURSEG Text _TEXT
@FILENAME Text APISUPT
@WORDSIZE Text 2
STANDALONE Text 1
_API_SP (_api_sp) Word ----:---- Extern
_API_SS (_api_ss) Word ----:---- Extern
_RESTORE_STACK (_restore_stack) Far _TEXT:002B
_SET_STACK (_set_stack) Far _TEXT:0000
_USR_SP (_usr_sp) Word ----:---- Extern
_USR_SS (_usr_ss) Word ----:---- Extern
Groups & Segments Bit Size Align Combine Class
DGROUP Group
_BSS 16 0000 Word Public BSS
_BSSEND 16 0000 Byte Public STACK
_DATA 16 0000 Word Public DATA
_TEXT 16 004E Byte Public CODE
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?