home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
PASCAL
/
PERFORM
/
GOODCHAR.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-03-28
|
5KB
|
147 lines
{$IFDEF VER70}
{$A+,B-,D-,E-,F-,G-,I-,L-,N-,O-,P-,Q-,R-,S+,T-,V-,X+}
{$ELSE}
{$A+,B-,D-,E-,F-,G-,I-,L-,N-,O-,R-,S+,V-,X+}
{$ENDIF}
{$M 16384,0,655360}
var TimerTick: Word absolute $0040:$006C;
StartTick: Word;
Normaliseer,Reps,Reps1,Reps2,Reps3,Reps4,Reps5: LongInt;
Type CharSet = Set of Char;
Var CSet: CharSet;
CStr: String;
C: Char;
function GoodChar1(C: Char; S: CharSet): Boolean;
begin
GoodChar1 := C in S
end {GoodChar1};
function GoodChar2(C: Char; var Str: String): Boolean;
begin
GoodChar2 := Pos(C,Str) > 0
end {GoodChar2};
function GoodChar3(C: Char; Str: String): Boolean; Assembler;
ASM
cld
les DI,Str
mov AL,ES:[DI]
xor AH,AH
inc DI
mov CX,AX { If Length(s) = 0 Then Exit }
jcxz @1 { AX = 0 ==> AL = False }
mov AL,C { Scan for first occurence of c }
INC CX
repne SCASB
mov AL,False
jcxz @1 { GoodChar is True if not at end of string }
mov AL,True
@1:
end {GoodChar3};
function GoodChar4(C: Char; Str: String): Boolean;
InLine(
$5F/ { POP DI }
$07/ { POP ES }
$FC/ { CLD }
$26/ { ES: }
$8A/$0D/ { MOV CL,[DI] }
$30/$ED/ { XOR CH,CH }
$41/ { INC CX }
{ ; Een verder dan Length(Str). }
$47/ { INC DI }
$58/ { POP AX }
$F2/$AE/ { REPNE SCASB }
$91 { XCHG CX, AX }
); { ; als CX = 0, dan niet in Str }
function GoodChar5(C: Char; var _Set): Boolean;
InLine(
$5F/ { pop DI }
$07/ { pop ES }
$58/ { pop AX }
$30/$E4/ { xor AH,AH }
$89/$C3/ { mov BX,AX }
$B1/$03/ { mov CL,3 }
$D3/$EB/ { shr BX,CL }
$88/$C1/ { mov CL,AL }
$80/$E1/$07/ { and CL,$07 }
$B0/$01/ { mov AL,1 }
$D2/$E0/ { shl AL,CL }
$26/ { ES: }
$22/$01/ { and AL,BYTE PTR [DI+BX] }
$D2/$E8); { shr AL,CL }
begin
CSet := ['a'..'z'];
CStr := 'abcdefghijklmnopqrstuvwxyz';
Reps1 := 0;
Reps2 := 0;
Reps3 := 0;
Reps4 := 0;
for C:='a' to 'z' do if (Ord(C) - ord('a')) mod 5 = 1 then
begin
write(C:2);
Reps := 0;
StartTick := TimerTick;
while StartTick = TimerTick do {wait for end of TimerTick};
StartTick := TimerTick;
repeat
if GoodChar1(C,CSet) then Inc(Reps)
else Dec(Reps);
until StartTick <> TimerTick;
Inc(Reps1,Reps);
Normaliseer := Reps;
write(100 * Reps / Normaliseer:6:0);
Reps := 0;
StartTick := TimerTick;
while StartTick = TimerTick do {wait for end of TimerTick};
StartTick := TimerTick;
repeat
if GoodChar2(C,CStr) then Inc(Reps)
else Dec(Reps);
until StartTick <> TimerTick;
Inc(Reps2,Reps);
write(100 * Reps / Normaliseer:6:0);
Reps := 0;
StartTick := TimerTick;
while StartTick = TimerTick do {wait for end of TimerTick};
StartTick := TimerTick;
repeat
if GoodChar3(C,CStr) then Inc(Reps)
else Dec(Reps);
until StartTick <> TimerTick;
Inc(Reps3,Reps);
write(100 * Reps / Normaliseer:6:0);
Reps := 0;
StartTick := TimerTick;
while StartTick = TimerTick do {wait for end of TimerTick};
StartTick := TimerTick;
repeat
if GoodChar4(C,CStr) then Inc(Reps)
else Dec(Reps);
until StartTick <> TimerTick;
Inc(Reps4,Reps);
write(100 * Reps / Normaliseer:6:0);
Reps := 0;
StartTick := TimerTick;
while StartTick = TimerTick do {wait for end of TimerTick};
StartTick := TimerTick;
repeat
if GoodChar5(C,CSet) then Inc(Reps)
else Dec(Reps);
until StartTick <> TimerTick;
Inc(Reps5,Reps);
writeln(100 * Reps / Normaliseer:6:0)
end
end.