|
|
1.1 ! root 1: .xlist ! 2: include mdef ! 3: page 63,132 ! 4: .ilist ! 5: ; MSWAIT: Wait up to 30000 milliseconds ! 6: ; July 1992, Steve D. @ Vertrauen 714 529-9547 ! 7: ! 8: setmod %mm ;set memory model ! 9: public _mswait,_mswtyp ! 10: ! 11: .data ! 12: _mswtyp db 0 ;system type for idle loop ! 13: dosidl equ 1 ;use int 28h ! 14: os2idl equ 2 ;use int 2fh function 1680h ! 15: .code ! 16: clkvct dd 0 ;saved int 1ch vector ! 17: brkvct dd 0 ;saved int 1bh vector ! 18: waitct dw 0 ;local 8254 tick count ! 19: cbrk db 0 ;ctrl-break key pressed ! 20: ! 21: clkisr proc ;interrupt 1ch (55ms tick) service routine ! 22: dec mw cs:waitct ! 23: jmp ml cs:clkvct ;exec prior service routine ! 24: clkisr endp ! 25: ! 26: brkisr proc ;interrupt 1bh (ctrl-break) service routine ! 27: mov mb cs:cbrk,-1 ;ctrl-break depressed, set abort flag ! 28: jmp ml cs:brkvct ;exec prior service routine ! 29: brkisr endp ! 30: ! 31: _mswait proc ! 32: push bp ! 33: mov bp,sp ! 34: ! 35: mov al,mb _mswtyp ! 36: push ax ;wait type flag at [bp-2] ! 37: ! 38: push es ! 39: push ds ! 40: ! 41: mov ax,351bh ! 42: int 21h ;get ctrl-break vector ! 43: mov mw cs:brkvct,bx ! 44: mov mw cs:brkvct+2,es ;save old service routine address ! 45: ! 46: mov mb cs:cbrk,0 ;clear abort flag ! 47: mov ah,25h ! 48: push cs ! 49: pop ds ;data segment is now inaccessible ! 50: mov dx,os brkisr ! 51: int 21h ;set new interrupt service routine ! 52: ! 53: mov ax,30000 ;maximal wait ! 54: mov dx,pb[bp] ;wait time in milliseconds ! 55: cmp ax,dx ! 56: jc @f ! 57: xchg ax,dx ;within range, use specification ! 58: @@: xor dx,dx ;milliseconds in dx:ax ! 59: sub ax,10 ;0-64 yields 55 ! 60: ja @f ! 61: mov ax,dx ;must be at least 0 ! 62: @@: mov cx,55 ;milliseconds per ctc interrupt ! 63: div cx ! 64: mov mw cs:waitct,ax ;number of ctc interrupts to wait ! 65: ! 66: pushf ;detect cpu type ! 67: mov ax,4000h ! 68: push ax ! 69: popf ! 70: pushf ! 71: pop ax ! 72: popf ! 73: and ah,0c0h ! 74: js msxt ;80186 or earlier ! 75: jz msxt ;80286 ! 76: ! 77: .386 ;80386 ! 78: pushad ! 79: mov ax,2b01h ;set date (get desqview version) ! 80: mov cx,4445h ;DE ! 81: mov dx,5351h ;SQ ! 82: int 21h ! 83: not al ;zero if desqview not running ! 84: mov mb -1[bp],al ! 85: ! 86: xor cx,cx ;running count in cx ! 87: mov ax,40h ! 88: mov es,ax ! 89: mov bx,6ch ;address bios clock ! 90: ! 91: stwt: mov edx,ml es:[bx] ! 92: lpwt: test cs:cbrk,-1 ! 93: jnz s mabt ;exit on ctrl-break ! 94: push edx ! 95: test mb -1[bp],-1 ! 96: jz s @f ;not under desqview ! 97: mov ax,1000h ! 98: int 15h ;surrender time slice, desqview ! 99: jmp s ckwt ;continue ! 100: @@: test mb -2[bp],os2idl ! 101: jz s ckwt ;no int 2fh call ! 102: mov ax,1680h ! 103: int 2fh ;surrender time slice, os/2 ! 104: ckwt: test mb -2[bp],dosidl ! 105: jz s @f ;no int 28h call ! 106: int 28h ;idle ! 107: @@: pop edx ! 108: mov eax,ml es:[bx] ! 109: mov esi,eax ;save latest clock value ! 110: sub eax,edx ! 111: jz lpwt ;wait for clock change ! 112: jc stwt ;crossed midnight, reset ! 113: mov edx,esi ;set most current value ! 114: cmp eax,7fh ! 115: jnc s mabt ;swapped out more than 7 seconds ! 116: add cx,ax ;add to running total ! 117: cmp cx,cs:waitct ;static maximal value ! 118: jna lpwt ;not expired, continue ! 119: ! 120: mabt: popad ! 121: mov ax,386 ;for test purposes ! 122: test mb -1[bp],-1 ! 123: jz s msex ! 124: mov ax,10386 ! 125: jmp s msex ! 126: ! 127: msxt: .8086 ! 128: mov ax,351ch ! 129: int 21h ;get int 1ch vector ! 130: mov mw cs:clkvct,bx ! 131: mov mw cs:clkvct+2,es ;save old service routine address ! 132: ! 133: mov ah,25h ! 134: push cs ! 135: pop ds ! 136: mov dx,os clkisr ! 137: int 21h ;set new interrupt service routine ! 138: ! 139: mswl: test cs:cbrk,-1 ! 140: jnz @f ;exit on ctrl-break ! 141: mov ax,cs:waitct ! 142: or ax,ax ! 143: jns mswl ;wait for negative count ! 144: ! 145: @@: mov ax,251ch ! 146: lds dx,cs:clkvct ! 147: int 21h ;restore old clock sr vector ! 148: xor ax,ax ;return zero ! 149: msex: push ax ! 150: mov ax,251bh ! 151: lds dx,cs:brkvct ! 152: int 21h ;restore old ctrl-break sr vector ! 153: pop ax ! 154: pop ds ! 155: pop es ! 156: pop bx ;wait type flag ! 157: pop bp ! 158: ret ! 159: _mswait endp ! 160: end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.