timer.asm
来自「开放源码的编译器open watcom 1.6.0版的源代码」· 汇编 代码 · 共 360 行 · 第 1/2 页
ASM
360 行
mov eax,_SampleIndex ; - - if( SampleIndex >= Ceiling
cmp eax,_Ceiling ; - - - then
_if ge ; - - - ...
cmp _CallGraphMode,0 ; - - - if( CallGraphMode )
_if ne ; - - - - then
dec _SampleIndex ; - - - - --SampleCount
mov eax,_LastSampleIndex ; - - - - SampleIndex = LastSampleIndex
mov _SampleIndex,eax ; - - - - ...
_else ; - - - else
dec _SampleIndex ; - - - - --SampleIndex
_endif ; - - - endif
mov _LostData,1 ; - - - LostData = TRUE
_endif ; - - endif
_endif ; - endif
_endif ; endif
dec dword ptr _InsiderTime ; --InsiderTime
pop ecx ; ...
pop edx ; ...
pop ebx ; ...
pop eax ; ...
pop es ; restore registers
pop ds ; ...
push cs:savefl ; restore stack frame
push cs:savecs ; ...
push cs:saveeip ; ...
jmp l3
l3: iretd
inttm endp
public GrabVects_
GrabVects_ proc near
push ecx ; save registers
push ebx ; ...
push edx ; ...
push es ; ...
push ds ; ...
mov dataseg,ds ; save data segment
mov ebx,'PHAR' ; get Dos extender version
mov ah,30H ; ...
int 21H ; ...
sub bl,'0' ; ...
mov _XVersion,bl ; ...
mov ax,250cH ; get hw interrupt vectors
int 21H ; ...
movzx eax,al ; ... extend
push eax ; save it
cmp _XVersion,3 ; if version >= 3
_if ge ; - then
mov ax,2502H ; - get old vector
pop ecx ; - ...
push ecx
int 21H ; - ...
mov iTMseg,es ; - stash it
mov iTMoff,ebx ; - ...
pop ecx ; - ...
mov ax,2504H ; - set new vector
lea edx,inttm ; - ...
push cs ; - ...
pop ds ; - ...
int 21H ; - ...
_else ; else
pop ebx ; - point to the IDT entry
shl ebx,3 ; - ...
mov ax,50h ; - ...
mov es,ax ; - ...
cli ; - interrupts off
mov ax,es:[ebx].hoffs ; - save IDT entry
mov tmhoffs,ax ; - ...
mov ax,es:[ebx].loffs ; - ...
mov tmloffs,ax ; - ...
mov ax,es:[ebx].select ; - ...
mov tmselect,ax ; - ...
mov al,es:[ebx].arights ; - ...
mov tmarights,al ; - ...
lea eax,inttm ; - set new timer handler
mov es:[ebx].loffs,ax ; - ...
shr eax,16 ; - ...
mov es:[ebx].hoffs,ax ; - ...
mov es:[ebx].select,cs ; - ...
mov es:[ebx].arights,08EH ; - ...
sti ; - interrupts back on
_endif ; endif
epi: pop ds ; restore registers
pop es ; ...
pop edx ; ...
pop ebx ; ...
pop ecx ; ...
ret ; return to caller
GrabVects_ endp
public ReleVects_
ReleVects_ proc near
push ecx ; save registers
push edx ; ...
push ebx ; ...
push ds ; ...
push es ; ...
cmp _XVersion,3 ; if version >= 3
_if ge ; - then
nop
mov ax,250cH ; - get hw interrupt vectors
int 21H ; - ...
mov cl,al ; - restore handler
mov edx,iTMoff ; - ...
mov ds,iTMseg ; - ...
mov ax,2504H ; - ...
int 21H
_else ; else
cmp byte ptr tmarights,0 ; - if we have taken it over
_if ne ; - - then
mov ax,250cH ; - - get hw interrupt vectors
int 21H ; - - ...
movzx ebx,al ; - - ...
shl ebx,3 ; - - ...
mov ax,50h ; - - point to IDT
mov es,ax ; - - ...
cli ; - ...
mov ax,tmhoffs ; - ...
mov es:[ebx].hoffs,ax ; - ...
mov ax,tmloffs ; - ...
mov es:[ebx].loffs,ax ; - save offset
mov ax,tmselect ; - ...
mov es:[ebx].select,ax ; - save offset
mov al,tmarights ; - ...
mov es:[ebx].arights,al ; - ...
sti ; - ...
_endif ; - endif
_endif ; endif
pop es ; restore registers
pop ds ; ...
pop ebx ; ...
pop edx ; ...
pop ecx ; ...
ret ; return to caller
ReleVects_ endp
public ReadRealClk_
ReadRealClk_ proc near
push ebx ; save secp
push edx ; save minp
push eax ; save hourp
mov ah,2 ; read real time clock
int 1aH ; ...
pop eax ; *secp = sec
movzx ebx,ch ; ...
mov dword ptr [eax],ebx ; ...
pop eax ; *minp = min
movzx ebx,cl ; ...
mov dword ptr [eax],ebx ; ...
pop eax ; *hourp = hour
movzx ebx,dh ; ...
mov dword ptr [eax],ebx ; ...
ret
ReadRealClk_ endp
public SetBiosClk_
SetBiosClk_ proc near
push edx
mov dx,ax ; dx = low part of count
shr eax,10H ; cx = high part of count
mov cx,ax ; ...
mov ah,1 ; set bios count
int 1aH ; ...
pop edx
ret
SetBiosClk_ endp
_text ends
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?