|
|
1.1 root 1:
2: Microsoft Macro Assembler Version 5.10 7/22/93 04:16:00
3: mswait Page 1-1
4:
5:
6: ; MSWAIT: Wait up to 30000 milliseconds
7: ; July 1992, Steve D. @ Vertrauen 714 529-9547
8:
9: setmod %mm ;set memory model
10: public _mswait,_mswtyp
11:
12: .data
13: 0000 00 _mswtyp db 0 ;system type for idle loop
14: = 0001 dosidl equ 1 ;use int 28h
15: = 0002 os2idl equ 2 ;use int 2fh function 1680h
16: .code
17: 0000 00000000 clkvct dd 0 ;saved int 1ch vector
18: 0004 00000000 brkvct dd 0 ;saved int 1bh vector
19: 0008 0000 waitct dw 0 ;local 8254 tick count
20: 000A 00 cbrk db 0 ;ctrl-break key pressed
21:
22: 000B clkisr proc ;interrupt 1ch (55ms tick) service routine
23: 000B 2E: FF 0E 0008 R dec mw cs:waitct
24: 0010 2E: FF 2E 0000 R jmp ml cs:clkvct ;exec prior service routine
25: 0015 clkisr endp
26:
27: 0015 brkisr proc ;interrupt 1bh (ctrl-break) service routine
28: 0015 2E: C6 06 000A R FF mov mb cs:cbrk,-1 ;ctrl-break depressed, set abort flag
29: 001B 2E: FF 2E 0004 R jmp ml cs:brkvct ;exec prior service routine
30: 0020 brkisr endp
31:
32: 0020 _mswait proc
33: 0020 55 push bp
34: 0021 8B EC mov bp,sp
35:
36: 0023 A0 0000 R mov al,mb _mswtyp
37: 0026 50 push ax ;wait type flag at [bp-2]
38:
39: 0027 06 push es
40: 0028 1E push ds
41:
42: 0029 B8 351B mov ax,351bh
43: 002C CD 21 int 21h ;get ctrl-break vector
44: 002E 2E: 89 1E 0004 R mov mw cs:brkvct,bx
45: 0033 2E: 8C 06 0006 R mov mw cs:brkvct+2,es ;save old service routine address
46:
47: 0038 2E: C6 06 000A R 00 mov mb cs:cbrk,0 ;clear abort flag
48: 003E B4 25 mov ah,25h
49: 0040 0E push cs
50: 0041 1F pop ds ;data segment is now inaccessible
51: 0042 BA 0015 R mov dx,os brkisr
52: 0045 CD 21 int 21h ;set new interrupt service routine
53:
54: 0047 B8 7530 mov ax,30000 ;maximal wait
55: 004A 8B 56 06 mov dx,pb[bp] ;wait time in milliseconds
56: 004D 3B C2 cmp ax,dx
57: 004F 72 01 jc @f
58: 0051 92 xchg ax,dx ;within range, use specification
59: 0052 33 D2 @@: xor dx,dx ;milliseconds in dx:ax
60: 0054 2D 000A sub ax,10 ;0-64 yields 55
61: 0057 77 02 ja @f
62: 0059 8B C2 mov ax,dx ;must be at least 0
63: 005B B9 0037 @@: mov cx,55 ;milliseconds per ctc interrupt
64: 005E F7 F1 div cx
65:
66: Microsoft Macro Assembler Version 5.10 7/22/93 04:16:00
67: mswait Page 1-2
68:
69:
70: 0060 2E: A3 0008 R mov mw cs:waitct,ax ;number of ctc interrupts to wait
71:
72: 0064 9C pushf ;detect cpu type
73: 0065 B8 4000 mov ax,4000h
74: 0068 50 push ax
75: 0069 9D popf
76: 006A 9C pushf
77: 006B 58 pop ax
78: 006C 9D popf
79: 006D 80 E4 C0 and ah,0c0h
80: 0070 78 7E js msxt ;80186 or earlier
81: 0072 74 7C jz msxt ;80286
82:
83: .386 ;80386
84: 0074 66| 60 pushad
85: 0076 B8 2B01 mov ax,2b01h ;set date (get desqview version)
86: 0079 B9 4445 mov cx,4445h ;DE
87: 007C BA 5351 mov dx,5351h ;SQ
88: 007F CD 21 int 21h
89: 0081 F6 D0 not al ;zero if desqview not running
90: 0083 88 46 FF mov mb -1[bp],al
91:
92: 0086 33 C9 xor cx,cx ;running count in cx
93: 0088 B8 0040 mov ax,40h
94: 008B 8E C0 mov es,ax
95: 008D BB 006C mov bx,6ch ;address bios clock
96:
97: 0090 26: 66| 8B 17 stwt: mov edx,ml es:[bx]
98: 0094 2E: F6 06 000A R FF lpwt: test cs:cbrk,-1
99: 009A 75 44 jnz s mabt ;exit on ctrl-break
100: 009C 66| 52 push edx
101: 009E F6 46 FF FF test mb -1[bp],-1
102: 00A2 74 07 jz s @f ;not under desqview
103: 00A4 B8 1000 mov ax,1000h
104: 00A7 CD 15 int 15h ;surrender time slice, desqview
105: 00A9 EB 0B jmp s ckwt ;continue
106: 00AB F6 46 FE 02 @@: test mb -2[bp],os2idl
107: 00AF 74 05 jz s ckwt ;no int 2fh call
108: 00B1 B8 1680 mov ax,1680h
109: 00B4 CD 2F int 2fh ;surrender time slice, os/2
110: 00B6 F6 46 FE 01 ckwt: test mb -2[bp],dosidl
111: 00BA 74 02 jz s @f ;no int 28h call
112: 00BC CD 28 int 28h ;idle
113: 00BE 66| 5A @@: pop edx
114: 00C0 26: 66| 8B 07 mov eax,ml es:[bx]
115: 00C4 66| 8B F0 mov esi,eax ;save latest clock value
116: 00C7 66| 2B C2 sub eax,edx
117: 00CA 74 C8 jz lpwt ;wait for clock change
118: 00CC 72 C2 jc stwt ;crossed midnight, reset
119: 00CE 66| 8B D6 mov edx,esi ;set most current value
120: 00D1 66| 83 F8 7F cmp eax,7fh
121: 00D5 73 09 jnc s mabt ;swapped out more than 7 seconds
122: 00D7 03 C8 add cx,ax ;add to running total
123: 00D9 2E: 3B 0E 0008 R cmp cx,cs:waitct ;static maximal value
124: 00DE 76 B4 jna lpwt ;not expired, continue
125:
126: 00E0 66| 61 mabt: popad
127: 00E2 B8 0182 mov ax,386 ;for test purposes
128: 00E5 F6 46 FF FF test mb -1[bp],-1
129:
130: Microsoft Macro Assembler Version 5.10 7/22/93 04:16:00
131: mswait Page 1-3
132:
133:
134: 00E9 74 39 jz s msex
135: 00EB B8 2892 mov ax,10386
136: 00EE EB 34 jmp s msex
137:
138: 00F0 msxt: .8086
139: 00F0 B8 351C mov ax,351ch
140: 00F3 CD 21 int 21h ;get int 1ch vector
141: 00F5 2E: 89 1E 0000 R mov mw cs:clkvct,bx
142: 00FA 2E: 8C 06 0002 R mov mw cs:clkvct+2,es ;save old service routine address
143:
144: 00FF B4 25 mov ah,25h
145: 0101 0E push cs
146: 0102 1F pop ds
147: 0103 BA 000B R mov dx,os clkisr
148: 0106 CD 21 int 21h ;set new interrupt service routine
149:
150: 0108 2E: F6 06 000A R FF mswl: test cs:cbrk,-1
151: 010E 75 08 jnz @f ;exit on ctrl-break
152: 0110 2E: A1 0008 R mov ax,cs:waitct
153: 0114 0B C0 or ax,ax
154: 0116 79 F0 jns mswl ;wait for negative count
155:
156: 0118 B8 251C @@: mov ax,251ch
157: 011B 2E: C5 16 0000 R lds dx,cs:clkvct
158: 0120 CD 21 int 21h ;restore old clock sr vector
159: 0122 33 C0 xor ax,ax ;return zero
160: 0124 50 msex: push ax
161: 0125 B8 251B mov ax,251bh
162: 0128 2E: C5 16 0004 R lds dx,cs:brkvct
163: 012D CD 21 int 21h ;restore old ctrl-break sr vector
164: 012F 58 pop ax
165: 0130 1F pop ds
166: 0131 07 pop es
167: 0132 5B pop bx ;wait type flag
168: 0133 5D pop bp
169: 0134 CB ret
170: 0135 _mswait endp
171: end
172:
173:
174: Microsoft Macro Assembler Version 5.10 7/22/93 04:16:00
175: mswait Symbols-1
176:
177:
178: Macros:
179:
180: N a m e Lines
181:
182: .EOPG . . . . . . . . . . . . . 4
183: .ILIST . . . . . . . . . . . . . 2
184: ASA . . . . . . . . . . . . . . 1
185: ASTRUC . . . . . . . . . . . . . 6
186: ASYN . . . . . . . . . . . . . . 0
187: DA . . . . . . . . . . . . . . . 4
188: DBL . . . . . . . . . . . . . . 2
189: DBWW . . . . . . . . . . . . . . 2
190: DSA . . . . . . . . . . . . . . 4
191: DSB . . . . . . . . . . . . . . 4
192: DSS . . . . . . . . . . . . . . 8
193: DSTRUC . . . . . . . . . . . . . 8
194: DV . . . . . . . . . . . . . . . 5
195: INCL . . . . . . . . . . . . . . 5
196: SETMOD . . . . . . . . . . . . . 0
197:
198: Segments and Groups:
199:
200: N a m e Size Length Align Combine Class
201:
202: DGROUP . . . . . . . . . . . . . GROUP
203: _DATA . . . . . . . . . . . . 16 Bit 0001 WORD PUBLIC 'DATA'
204: MSWAIT_TEXT . . . . . . . . . . 16 Bit 0135 WORD PUBLIC 'CODE'
205:
206: Symbols:
207:
208: N a m e Type Value Attr
209:
210: AA . . . . . . . . . . . . . . . TEXT .model large
211:
212: BRKISR . . . . . . . . . . . . . F PROC 0015 MSWAIT_TEXT Length = 000B
213: BRKVCT . . . . . . . . . . . . . L DWORD 0004 MSWAIT_TEXT
214:
215: CBRK . . . . . . . . . . . . . . L BYTE 000A MSWAIT_TEXT
216: CKWT . . . . . . . . . . . . . . L NEAR 00B6 MSWAIT_TEXT
217: CLKISR . . . . . . . . . . . . . F PROC 000B MSWAIT_TEXT Length = 000A
218: CLKVCT . . . . . . . . . . . . . L DWORD 0000 MSWAIT_TEXT
219:
220: DOSIDL . . . . . . . . . . . . . NUMBER 0001
221: DS1 . . . . . . . . . . . . . . TEXT label byte
222: DS2 . . . . . . . . . . . . . . TEXT label word
223: DS4 . . . . . . . . . . . . . . TEXT label dword
224: DS6 . . . . . . . . . . . . . . TEXT label fword
225: DS8 . . . . . . . . . . . . . . TEXT label qword
226:
227: LISTON . . . . . . . . . . . . . NUMBER 0001
228: LPWT . . . . . . . . . . . . . . L NEAR 0094 MSWAIT_TEXT
229:
230: MABT . . . . . . . . . . . . . . L NEAR 00E0 MSWAIT_TEXT
231: MB . . . . . . . . . . . . . . . TEXT byte ptr
232: MDLC . . . . . . . . . . . . . . TEXT compact
233: MDLH . . . . . . . . . . . . . . TEXT huge
234: MDLL . . . . . . . . . . . . . . TEXT large
235: MDLM . . . . . . . . . . . . . . TEXT medium
236:
237: Microsoft Macro Assembler Version 5.10 7/22/93 04:16:00
238: mswait Symbols-2
239:
240:
241: MDLS . . . . . . . . . . . . . . TEXT small
242: ML . . . . . . . . . . . . . . . TEXT dword ptr
243: MM . . . . . . . . . . . . . . . TEXT l
244: MSEX . . . . . . . . . . . . . . L NEAR 0124 MSWAIT_TEXT
245: MSWL . . . . . . . . . . . . . . L NEAR 0108 MSWAIT_TEXT
246: MSXT . . . . . . . . . . . . . . L NEAR 00F0 MSWAIT_TEXT
247: MW . . . . . . . . . . . . . . . TEXT word ptr
248:
249: OS . . . . . . . . . . . . . . . TEXT offset
250: OS2IDL . . . . . . . . . . . . . NUMBER 0002
251:
252: PB . . . . . . . . . . . . . . . NUMBER 0006
253:
254: S . . . . . . . . . . . . . . . TEXT short
255: STWT . . . . . . . . . . . . . . L NEAR 0090 MSWAIT_TEXT
256:
257: WAITCT . . . . . . . . . . . . . L WORD 0008 MSWAIT_TEXT
258:
259: @0 . . . . . . . . . . . . . . . L NEAR 0052 MSWAIT_TEXT
260: @1 . . . . . . . . . . . . . . . L NEAR 005B MSWAIT_TEXT
261: @2 . . . . . . . . . . . . . . . L NEAR 00AB MSWAIT_TEXT
262: @3 . . . . . . . . . . . . . . . L NEAR 00BE MSWAIT_TEXT
263: @4 . . . . . . . . . . . . . . . L NEAR 0118 MSWAIT_TEXT
264: @CODE . . . . . . . . . . . . . TEXT mswait_TEXT
265: @CODESIZE . . . . . . . . . . . TEXT 1
266: @CPU . . . . . . . . . . . . . . TEXT 257
267: @DATASIZE . . . . . . . . . . . TEXT 1
268: @FILENAME . . . . . . . . . . . TEXT mswait
269: @VERSION . . . . . . . . . . . . TEXT 510
270: _mswait . . . . . . . . . . . . F PROC 0020 MSWAIT_TEXT Global Length = 0115
271: _mswtyp . . . . . . . . . . . . L BYTE 0000 _DATA Global
272:
273:
274: 340 Source Lines
275: 356 Total Lines
276: 74 Symbols
277:
278: 47118 + 348476 Bytes symbol space free
279:
280: 0 Warning Errors
281: 0 Severe Errors
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.