home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1998 September / PCO_0998.ISO / filesbbs / dos / sbbs_src.exe / MSWAIT / MSWAIT.LST < prev   
Encoding:
File List  |  1993-07-22  |  10.1 KB  |  282 lines

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