Fix to pause after command (!) invocation.
[unix-history] / usr / src / usr.bin / tn3270 / distribution / sys_dos / spintasm.asm
CommitLineData
4599d553 1;
84f75426 2; The code in this file complete the spint calls
4599d553
GM
3;
4
84f75426 5spint struc
4599d553 6; union REGS
84f75426
GM
7spint_ax dw 1
8spint_bx dw 1
9spint_cx dw 1
10spint_dx dw 1
11spint_si dw 1
12spint_di dw 1
13spint_cflag dw 1
4599d553 14; struct SREGS
84f75426
GM
15spint_es dw 1
16spint_cs dw 1
17spint_ss dw 1
18spint_ds dw 1
4599d553 19; int intno
84f75426 20spint_intno dw 1
4599d553 21; int done
84f75426 22spint_done dw 1
4599d553 23; int rc
84f75426 24spint_rc dw 1
4599d553 25;
84f75426 26spint ends
4599d553
GM
27
28
29ENTER MACRO
30 ; Begin enter
31 push bp
32 mov bp,sp
33
34 push ax
35 push bx
36 push cx
37 push dx
38 push bp
39 push di
40 push si
41 push ds
42 push es
43 pushf
44
84f75426
GM
45 mov cs:start_sp, sp
46 mov cs:start_ss, ss
4599d553
GM
47 ; End enter
48 ENDM
49
50LEAVE MACRO
51 ; Begin leave
84f75426
GM
52 cli
53 mov sp, cs:start_sp
54 mov ss, cs:start_ss
55 sti
4599d553
GM
56
57 popf
58 pop es
59 pop ds
60 pop si
61 pop di
62 pop bp
63 pop dx
64 pop cx
65 pop bx
66 pop ax
67
68 mov sp,bp
69 pop bp
70 ret
71 ; End leave
72 ENDM
73
74GETREGS MACRO wherefrom
75 mov si, wherefrom
84f75426
GM
76 mov spint_segment, ds
77 mov spint_offset, si
78
79 mov ax, spint_ax[si]
80 mov bx, spint_bx[si]
81 mov cx, spint_cx[si]
82 mov dx, spint_dx[si]
83 ; XXX mov si, spint_si[si]
84 mov di, spint_di[si]
85 mov es, spint_es[si]
4599d553 86 ; Now, need to do DS, SI
84f75426
GM
87 push spint_ds[si]
88 mov si, spint_si[si]
4599d553
GM
89 pop ds
90 ENDM
91
92
93SETREGS MACRO
94 mov cs:old_si, si
95 mov cs:old_ds, ds
96
84f75426
GM
97 mov ds, cs:spint_segment
98 mov si, cs:spint_offset
4599d553 99
84f75426
GM
100 mov spint_ax[si], ax
101 mov spint_bx[si], bx
102 mov spint_cx[si], cx
103 mov spint_dx[si], dx
4599d553 104
84f75426
GM
105 mov spint_si[si], si
106 mov spint_di[si], di
4599d553 107
84f75426
GM
108 mov spint_cs[si], cs
109 mov spint_ds[si], ds
110 mov spint_es[si], es
111 mov spint_ss[si], ss
4599d553
GM
112 ; now, need to do SI, DS
113 mov ax, old_si
84f75426 114 mov spint_si[si], ax
4599d553 115 mov ax, old_ds
84f75426 116 mov spint_ds[si], ax
4599d553
GM
117 ENDM
118
119
3dfa901b
GM
120_TEXT segment byte public 'CODE'
121_TEXT ends
122
123_DATA segment word public 'DATA'
124_DATA ends
125
126CONST segment word public 'CONST'
127CONST ends
128
129_BSS segment word public 'BSS'
130_BSS ends
131
132DGROUP group CONST, _BSS, _DATA
133
134 assume cs:_TEXT, ds:DGROUP, ss:DGROUP, es:DGROUP
135
136_TEXT segment
137
84f75426
GM
138start_sp dw 1 dup (?) ; For use in our 'longjmp'
139start_ss dw 1 dup (?) ; For use in our 'longjmp'
4599d553 140
84f75426
GM
141spint_segment dw 1 dup (?) ; Segment of spawn control block
142spint_offset dw 1 dup (?) ; Offset of spawn control block
4599d553 143
84f75426
GM
144old_si dw 1 dup (?) ; SI of interrupt issuer (temporary)
145old_ds dw 1 dup (?) ; DS of interrupt issuer (temporary)
4599d553 146
84f75426
GM
147issuer_ss dw 1 dup (?) ; ss of person who called us (permanent)
148issuer_sp dw 1 dup (?) ; sp of person who called us (permanent)
149
150int21_stack db 100 dup (?) ; Stack for int21.
4599d553 151
3dfa901b 152;
84f75426
GM
153; _spint_int gets control on an interrupt. It switches the stack
154; and does a 'return' from _spint_start.
3dfa901b 155;
84f75426 156 public __spint_int
3dfa901b 157
84f75426 158__spint_int proc near
4599d553 159 mov cs:issuer_sp, sp
84f75426
GM
160 mov cs:issuer_ss, ss
161 sti
3dfa901b 162
4599d553
GM
163 SETREGS
164
165 LEAVE
84f75426 166__spint_int endp
3dfa901b
GM
167
168;
84f75426
GM
169; _spint_start issues the dos interrupt after setting up the passed
170; registers. When control returns to it, it sets spint->done to non-zero.
3dfa901b 171;
84f75426 172 public __spint_start
3dfa901b 173
84f75426 174__spint_start proc near
4599d553 175 ENTER
3dfa901b 176
4599d553
GM
177 GETREGS 4[bp]
178
84f75426
GM
179 ; Now, switch to a different (short) stack. This is so
180 ; that our games won't mess up the stack int 21 (hardware and,
181 ; possibly, software) stores things on.
182
183 cli
184 mov cs:int21_stack, cs
185 mov ss, cs:int21_stack
186 mov sp, offset int21_stack
187 add sp, (length int21_stack) - 4
188 sti
189
4599d553
GM
190 int 21H ; Issue DOS interrupt
191
192 SETREGS
193
84f75426
GM
194 mov ds, cs:spint_segment
195 mov si, cs:spint_offset
196 mov spint_done[si], 1 ; We are done
4599d553
GM
197
198 LEAVE
84f75426 199__spint_start endp
3dfa901b
GM
200
201;
84f75426 202; After _spint_int has faked a return from start_spawn, we come here to
3dfa901b
GM
203; return to the interrupt issuer.
204;
84f75426 205 public __spint_continue
3dfa901b 206
84f75426 207__spint_continue proc near
4599d553 208 ENTER
3dfa901b 209
4599d553
GM
210 GETREGS 4[bp]
211
212 mov sp, cs:issuer_sp ; Restore SP
84f75426 213 mov ss, cs:issuer_ss ; Restore SS
4599d553
GM
214
215 iret
84f75426 216__spint_continue endp
3dfa901b
GM
217
218_TEXT ends
219
220 end