-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathxmisc.pas
92 lines (83 loc) · 1.73 KB
/
xmisc.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
{$mode TP}
{$PACKRECORDS 1}
unit xmisc;
interface
Type
TByteArray = array[0..0] of byte; {Array of bytes, useful for typecasting}
TIntArray = array[0..0] of integer; {Array of integers, useful for typecasting}
TWordArray = array[0..0] of integer; {Array of words, useful for typecasting}
TCharArray = array[0..0] of char; {Array of chars, useful for typecasting}
//function XIntToStr( n : integer; w : byte ) : string;
{ This function transforms the integer n into a string with with w}
//function XCompare( var a, b; l : word ) : boolean;
{ This function compares variables a and b for l bytes and, if equal
it returns TRUE. It returns FALSE otherwise}
//function XExists( filename : string ) : boolean;
{ This functions returns TRUE if the file "filename" exists. It
returns false otherwise}
//procedure XStrUpCase( var s : string );
{ This procedure makes all the characters in a string uppercase}
implementation
function xinttostr( n : integer; w : byte ) : string;
var
s : string;
begin
str( n:w, s );
xinttostr := s;
end;
(*
function xcompare( var a, b; l : word ) : boolean; assembler;
asm
cld
push ds
lds si, a
les di, b
mov cx, l
repe cmpsb
or cx, cx
jz @@Ok
mov ax, 0
jmp @@Done
@@Ok:
mov ax, 1
@@Done:
pop ds
end;
*)
function xexists( filename : string ) : boolean;
var
f : file;
tmp : boolean;
begin
{$I-}
assign( f, filename );
reset( f );
{$I+}
tmp := ioresult=0;
if tmp then close(f);
xexists := tmp;
end;
(*
procedure xstrupcase( var s : string ); assembler;
asm
les di, s
mov cx, 0
mov cl, es:[di]
inc di
or cl, cl
jz @@Done
@@ChangeChar:
mov al, es:[di]
cmp al, 'a'
jl @@Next
cmp al, 'z'
jg @@Next
sub al, 32
mov es:[di], al
@@Next:
inc di
loop @@ChangeChar
@@Done:
end;
*)
end.