home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 3
/
FREEWARE.BIN
/
ms_dos
/
cpu
/
cpu.asm
< prev
next >
Wrap
Assembly Source File
|
1980-01-02
|
2KB
|
165 lines
comment `
1990-05-05 Counting in Real Mode Procedure
`
.386p
rmCPU SEGMENT WORD USE16 PUBLIC 'CODE'
rmCPU ENDS
rmDATA SEGMENT WORD USE16 PUBLIC 'DATA'
rmDATA ENDS
CPU SEGMENT DWORD USE32 PUBLIC 'CODE'
CPU ENDS
DATA SEGMENT DWORD USE32 'DATA'
DATA ENDS
DGROUP GROUP rmDATA,DATA
ASSUME cs:CPU,ds:DGROUP,es:DGROUP
CPU SEGMENT
PUBLIC chktime
chktime PROC NEAR
push es
push ebx
push esi
push edi
mov ax,250fh
xor ebx,ebx
mov ecx,offset end_of_rm_proc
int 21h
jnb #r1
mov eax,-1
jmp #exit
#r1:
mov ebx,ecx
mov bx,offset __chktime
xor ecx,ecx
mov ax,250eh
int 21h
#exit:
pop edi
pop esi
pop ebx
pop es
ret ;32Bit Near Return
chktime endp
CPU ENDS
rmCPU segment
public __chktime
__chktime proc far
mov ax,cs
mov ds,ax
mov di,offset intr
mov word ptr [di],1 ; one shot mode
mov word ptr [di+2],offset intr_proc
mov word ptr [di+4],cs
mov word ptr [di+6],0 ; 1 second
mov word ptr [di+8],100
mov flag,1
mov ah,0
int 97H
test ah,ah
je #r1
mov eax,-1
jmp #exit
#r1:
xor ax,ax
xor bx,bx
mov di,1
mov si,offset flag
xor dx,dx
#loop1:
cmp bl,[si]
je #break1
add ax,di
adc dx,bx
jmp #loop1
#break1:
xchg dx,ax
shl eax,16
mov ax,dx
#exit:
ret ;16Bit Far Return
__chktime endp
public intr_proc
intr_proc proc far
mov ax,cs
mov ds,ax
mov byte ptr [flag],0
ret
intr_proc endp
rmCPU ends
rmDATA segment
flag dw ?
intr dw ? ;mode
dd ? ;Interrupt Procedure
dw ? ;Clock High Word
dw ? ;Clock Low Word
end_of_rm_proc:
rmDATA ends
end
********************************************************************
PUBLIC _cpuspeed
_cpuspeed PROC NEAR
push di
push si
mov ax,DGROUP
mov ds,ax
mov di,offset DGROUP:intr
mov byte ptr [di],1 ; one shot mode
mov word ptr [di+2],offset _chktime
mov word ptr [di+4],seg _chktime
mov word ptr [di+6],0 ; 1 second
mov word ptr [di+8],100
mov flag,1
cli
mov ah,0
int 97H
test ah,ah
je LS1
mov ax,0ffffH
mov dx,ax
sti
jmp LB1
LS1:
xor ax,ax
xor bx,bx
mov di,1
mov si,offset DGROUP:flag
xor dx,dx
sti
LL1:
cmp bl,[si]
je LB1
add ax,di
adc dx,bx
jmp LL1
LB1:
pop si
pop di
ret
_cpuspeed ENDP
_TEXT ENDS
END