mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-13 14:49:47 +02:00
+ added asm optimized implementations of StrLower() and StrUpper() for i8086
git-svn-id: trunk@37618 -
This commit is contained in:
parent
51489f9186
commit
44f04d39a4
@ -76,3 +76,107 @@ asm
|
||||
@@LStrEndNil:
|
||||
end;
|
||||
{$endif FPC_UNIT_HAS_STREND}
|
||||
|
||||
|
||||
{$ifndef FPC_UNIT_HAS_STRUPPER}
|
||||
{$define FPC_UNIT_HAS_STRUPPER}
|
||||
function strupper(p : pchar) : pchar;assembler;nostackframe;
|
||||
const
|
||||
{$ifdef FPC_X86_CODE_FAR}
|
||||
extra_param_offset = 2;
|
||||
{$else FPC_X86_CODE_FAR}
|
||||
extra_param_offset = 0;
|
||||
{$endif FPC_X86_CODE_FAR}
|
||||
asm
|
||||
mov bx, sp
|
||||
xor ax, ax
|
||||
{$ifdef FPC_X86_DATA_NEAR}
|
||||
mov dx, ds
|
||||
mov es, dx
|
||||
mov di, ss:[bx + 2 + extra_param_offset] // @p
|
||||
or di, di
|
||||
jz @@LStrUpperNil
|
||||
{$else FPC_X86_DATA_NEAR}
|
||||
les di, ss:[bx + 2 + extra_param_offset] // @p
|
||||
mov dx, es
|
||||
mov cx, dx
|
||||
or cx, di
|
||||
jz @@LStrUpperNil
|
||||
mov cx, ds
|
||||
mov ds, dx
|
||||
{$endif FPC_X86_DATA_NEAR}
|
||||
mov si, di
|
||||
mov bx, di
|
||||
{$ifdef FPC_ENABLED_CLD}
|
||||
cld
|
||||
{$endif FPC_ENABLED_CLD}
|
||||
@@LSTRUPPER1:
|
||||
lodsb
|
||||
cmp al, 'a'
|
||||
jb @@LSTRUPPER3
|
||||
cmp al, 'z'
|
||||
ja @@LSTRUPPER3
|
||||
sub al, 20h
|
||||
@@LSTRUPPER3:
|
||||
stosb
|
||||
or al, al
|
||||
jnz @@LSTRUPPER1
|
||||
xchg ax, bx { 1 byte shorter than a mov }
|
||||
{$ifndef FPC_X86_DATA_NEAR}
|
||||
mov ds, cx
|
||||
{$endif not FPC_X86_DATA_NEAR}
|
||||
@@LStrUpperNil:
|
||||
end;
|
||||
{$endif FPC_UNIT_HAS_STRUPPER}
|
||||
|
||||
|
||||
{$ifndef FPC_UNIT_HAS_STRLOWER}
|
||||
{$define FPC_UNIT_HAS_STRLOWER}
|
||||
function strlower(p : pchar) : pchar;assembler;nostackframe;
|
||||
const
|
||||
{$ifdef FPC_X86_CODE_FAR}
|
||||
extra_param_offset = 2;
|
||||
{$else FPC_X86_CODE_FAR}
|
||||
extra_param_offset = 0;
|
||||
{$endif FPC_X86_CODE_FAR}
|
||||
asm
|
||||
mov bx, sp
|
||||
xor ax, ax
|
||||
{$ifdef FPC_X86_DATA_NEAR}
|
||||
mov dx, ds
|
||||
mov es, dx
|
||||
mov di, ss:[bx + 2 + extra_param_offset] // @p
|
||||
or di, di
|
||||
jz @@LStrLowerNil
|
||||
{$else FPC_X86_DATA_NEAR}
|
||||
les di, ss:[bx + 2 + extra_param_offset] // @p
|
||||
mov dx, es
|
||||
mov cx, dx
|
||||
or cx, di
|
||||
jz @@LStrLowerNil
|
||||
mov cx, ds
|
||||
mov ds, dx
|
||||
{$endif FPC_X86_DATA_NEAR}
|
||||
mov si, di
|
||||
mov bx, di
|
||||
{$ifdef FPC_ENABLED_CLD}
|
||||
cld
|
||||
{$endif FPC_ENABLED_CLD}
|
||||
@@LSTRLOWER1:
|
||||
lodsb
|
||||
cmp al, 'A'
|
||||
jb @@LSTRLOWER3
|
||||
cmp al, 'Z'
|
||||
ja @@LSTRLOWER3
|
||||
add al, 20h
|
||||
@@LSTRLOWER3:
|
||||
stosb
|
||||
or al, al
|
||||
jnz @@LSTRLOWER1
|
||||
xchg ax, bx { 1 byte shorter than a mov }
|
||||
{$ifndef FPC_X86_DATA_NEAR}
|
||||
mov ds, cx
|
||||
{$endif not FPC_X86_DATA_NEAR}
|
||||
@@LStrLowerNil:
|
||||
end;
|
||||
{$endif FPC_UNIT_HAS_STRLOWER}
|
||||
|
Loading…
Reference in New Issue
Block a user