home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
PASCAL
/
PERFORM
/
UPPER.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-03-28
|
3KB
|
94 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}
unit Upper;
interface
{
Borland Pascal (Objects) 7.0
Author: Bob Swart, released to Public Domain 1/93
Code size: 360 bytes
Data size: 0 bytes
-------------------------------------------------------------------------
This unit contains functions and procedures for string capitalisation.
}
function Upper0({var} Str: String): String;
function Upper1(var Str: String): String;
procedure Upper2(var Str: String);
function Upper3(Str: String): String;
procedure Upper4(var Str: String);
InLine(
$8C/$DA/ { mov DX,DS }
$5E/ { pop SI }
$1F/ { pop DS }
$AC/ { lodsb }
$30/$E4/ { xor AH,AH }
$89/$C1/ { mov CX,AX }
$E3/$13/ { jcxz @3 }
$B3/Ord('a')/ { mov BL,'a' }
$B7/Ord('z')/ { mov BH,'z' }
$AC/ { @1: lodsb }
$38/$D8/ { cmp AL,BL }
$72/$08/ { jb @2 }
$38/$F8/ { cmp AL,BH }
$77/$04/ { ja @2 }
$80/$6C/$FF/$20/ { sub BYTE PTR [SI-01],$20 }
$E2/$F1/ { @2: loop @1 }
$8E/$DA); { @3: mov DS,DX }
implementation
function Upper0({var} Str: String): String;
var len: Byte absolute Str;
i: Integer;
begin
Upper0[0] := Char(len);
for i:=1 to len do Upper0[i] := UpCase(Str[len])
end {Upper0};
function Upper1(var Str: String): String;
var len: Byte absolute Str;
i: Integer;
begin
Upper1[0] := Char(len);
for i:=1 to len do Upper1[i] := UpCase(Str[len])
end {Upper1};
procedure Upper2(var Str: String);
var len: Byte absolute Str;
i: Integer;
begin
for i:=1 to len do Str[i] := UpCase(Str[i])
end {Upper2};
function Upper3(Str: String): String; Assembler;
ASM
mov DX,DS
lds SI,Str
les DI,@Result
cld
lodsb
stosb
xor AH,AH
mov CX,AX
jcxz @3
mov BL,'a'
mov BH,'z'
@1: lodsb
cmp AL,BL
jb @2
cmp AL,BH
ja @2
sub AL,$20
@2: stosb
loop @1
@3: mov DS,DX
end {Upper3};
end.