|
@@ -35,8 +35,8 @@ asm
|
|
|
{ dest in the copy loop }
|
|
|
subi r9,r3,1
|
|
|
subi r4,r4,1
|
|
|
- beq LStrCopyAligned
|
|
|
-LStrCopyAlignLoop:
|
|
|
+ beq .LStrCopyAligned
|
|
|
+.LStrCopyAlignLoop:
|
|
|
{ load next byte }
|
|
|
lbzu r0,1(r4)
|
|
|
{ end of string? }
|
|
@@ -44,9 +44,9 @@ LStrCopyAlignLoop:
|
|
|
{ store byte }
|
|
|
stbu r0,1(r9)
|
|
|
{ loop if misaligned bytes left and not end of string found }
|
|
|
- bdnzf eq,LStrCopyAlignLoop
|
|
|
- beq LStrCopyDone
|
|
|
-LStrCopyAligned:
|
|
|
+ bdnzf cr0*4+eq,.LStrCopyAlignLoop
|
|
|
+ beq .LStrCopyDone
|
|
|
+.LStrCopyAligned:
|
|
|
subi r4,r4,3
|
|
|
subi r9,r9,3
|
|
|
{ setup magic constants }
|
|
@@ -66,30 +66,30 @@ LStrCopyAligned:
|
|
|
{ load first 4 bytes }
|
|
|
lwzu r0,4(r4)
|
|
|
|
|
|
-LStrCopyAlignedLoop:
|
|
|
+.LStrCopyAlignedLoop:
|
|
|
{ test for zero byte }
|
|
|
add r10,r0,r8
|
|
|
andc r10,r10,r0
|
|
|
and. r10,r10,r7
|
|
|
- bne LStrCopyEndFound
|
|
|
+ bne .LStrCopyEndFound
|
|
|
stwu r0,4(r9)
|
|
|
{ load next 4 bytes (do it here so the load can begin while the }
|
|
|
{ the branch is processed) }
|
|
|
lwzu r0,4(r4)
|
|
|
- b LStrCopyAlignedLoop
|
|
|
-LStrCopyEndFound:
|
|
|
+ b .LStrCopyAlignedLoop
|
|
|
+.LStrCopyEndFound:
|
|
|
{ adjust for possible $01 bytes coming before the terminating 0 byte }
|
|
|
rlwinm r8,r0,7,0,31
|
|
|
andc r10,r10,r8
|
|
|
{ result is either 0, 8, 16 or 24 depending on which byte is zero }
|
|
|
cntlzw r10,r10
|
|
|
addi r9,r9,3
|
|
|
-LStrCopyWrapUpLoop:
|
|
|
+.LStrCopyWrapUpLoop:
|
|
|
subic. r10,r10,8
|
|
|
rlwinm r0,r0,8,0,31
|
|
|
stbu r0,1(r9)
|
|
|
- bge LStrCopyWrapUpLoop
|
|
|
-LStrCopyDone:
|
|
|
+ bge .LStrCopyWrapUpLoop
|
|
|
+.LStrCopyDone:
|
|
|
{ r3 still contains dest here }
|
|
|
end;
|
|
|
|
|
@@ -107,8 +107,8 @@ asm
|
|
|
mtctr r10
|
|
|
subi r3,r3,1
|
|
|
subi r4,r4,1
|
|
|
- beq LStrECopyAligned
|
|
|
-LStrECopyAlignLoop:
|
|
|
+ beq .LStrECopyAligned
|
|
|
+.LStrECopyAlignLoop:
|
|
|
{ load next byte }
|
|
|
lbzu r0,1(r4)
|
|
|
{ end of string? }
|
|
@@ -116,9 +116,9 @@ LStrECopyAlignLoop:
|
|
|
{ store byte }
|
|
|
stbu r0,1(r3)
|
|
|
{ loop if misaligned bytes left and not end of string found }
|
|
|
- bdnzf eq,LStrECopyAlignLoop
|
|
|
- beq LStrECopyDone
|
|
|
-LStrECopyAligned:
|
|
|
+ bdnzf cr0*4+eq,.LStrECopyAlignLoop
|
|
|
+ beq .LStrECopyDone
|
|
|
+.LStrECopyAligned:
|
|
|
subi r4,r4,3
|
|
|
subi r3,r3,3
|
|
|
{ setup magic constants }
|
|
@@ -141,7 +141,7 @@ LStrECopyAligned:
|
|
|
li r9,-32640 { 0x08080 }
|
|
|
andis. r9,r9,0x08080
|
|
|
}
|
|
|
-LStrECopyAlignedLoop:
|
|
|
+.LStrECopyAlignedLoop:
|
|
|
|
|
|
{ load next 4 bytes }
|
|
|
lwzu r0,4(r4)
|
|
@@ -150,22 +150,22 @@ LStrECopyAlignedLoop:
|
|
|
add r10,r0,r8
|
|
|
andc r10,r10,r0
|
|
|
and. r10,r10,r7
|
|
|
- bne LStrECopyEndFound
|
|
|
+ bne .LStrECopyEndFound
|
|
|
stwu r0,4(r3)
|
|
|
- b LStrECopyAlignedLoop
|
|
|
-LStrECopyEndFound:
|
|
|
+ b .LStrECopyAlignedLoop
|
|
|
+.LStrECopyEndFound:
|
|
|
{ adjust for possible $01 bytes coming before the terminating 0 byte }
|
|
|
rlwinm r8,r0,7,0,31
|
|
|
andc r10,r10,r8
|
|
|
{ result is either 0, 8, 16 or 24 depending on which byte is zero }
|
|
|
cntlzw r10,r10
|
|
|
addi r3,r3,3
|
|
|
-LStrECopyWrapUpLoop:
|
|
|
+.LStrECopyWrapUpLoop:
|
|
|
subic. r10,r10,8
|
|
|
rlwinm r0,r0,8,0,31
|
|
|
stbu r0,1(r3)
|
|
|
- bge LStrECopyWrapUpLoop
|
|
|
-LStrECopyDone:
|
|
|
+ bge .LStrECopyWrapUpLoop
|
|
|
+.LStrECopyDone:
|
|
|
{ r3 contains new dest here }
|
|
|
end;
|
|
|
|
|
@@ -180,17 +180,17 @@ asm
|
|
|
mtctr r5
|
|
|
subi r4,r4,1
|
|
|
subi r10,r3,1
|
|
|
-LStrlCopyLoop:
|
|
|
+.LStrlCopyLoop:
|
|
|
lbzu r0,1(r4)
|
|
|
cmplwi r0,0
|
|
|
stbu r0,1(r10)
|
|
|
- bdnzf cr0*4+eq, LStrlCopyLoop
|
|
|
+ bdnzf cr0*4+eq, .LStrlCopyLoop
|
|
|
{ if we stopped because we copied a #0, we're done }
|
|
|
- beq LStrlCopyDone
|
|
|
+ beq .LStrlCopyDone
|
|
|
{ otherwise add the #0 }
|
|
|
li r0,0
|
|
|
stb r0,1(r10)
|
|
|
-LStrlCopyDone:
|
|
|
+.LStrlCopyDone:
|
|
|
end;
|
|
|
|
|
|
|
|
@@ -208,13 +208,13 @@ asm
|
|
|
{ empty/invalid string? }
|
|
|
cmplwi r3,0
|
|
|
{ if yes, do nothing }
|
|
|
- beq LStrEndDone
|
|
|
+ beq .LStrEndDone
|
|
|
subi r3,r3,1
|
|
|
-LStrEndLoop:
|
|
|
+.LStrEndLoop:
|
|
|
lbzu r0,1(r3)
|
|
|
cmplwi r0,0
|
|
|
- bne LStrEndLoop
|
|
|
-LStrEndDone:
|
|
|
+ bne .LStrEndLoop
|
|
|
+.LStrEndDone:
|
|
|
end;
|
|
|
|
|
|
|
|
@@ -227,7 +227,7 @@ asm
|
|
|
{ use r0 instead of r3 for str1 since r3 contains result }
|
|
|
subi r9,r3,1
|
|
|
subi r4,r4,1
|
|
|
-LStrCompLoop:
|
|
|
+.LStrCompLoop:
|
|
|
{ load next chars }
|
|
|
lbzu r0,1(r9)
|
|
|
{ check if one is zero }
|
|
@@ -236,12 +236,12 @@ LStrCompLoop:
|
|
|
{ calculate difference }
|
|
|
sub. r3,r0,r10
|
|
|
{ if chars not equal, we're ready }
|
|
|
- bne LStrCompDone
|
|
|
+ bne .LStrCompDone
|
|
|
{ if they are equal and one is zero, then the other one is zero too }
|
|
|
{ and we're done as well (r3 also contains 0 then) }
|
|
|
{ otherwise loop }
|
|
|
- bne cr1,LStrCompLoop
|
|
|
-LStrCompDone:
|
|
|
+ bne cr1,.LStrCompLoop
|
|
|
+.LStrCompDone:
|
|
|
end;
|
|
|
|
|
|
|
|
@@ -258,10 +258,10 @@ asm
|
|
|
cmplwi r5,0
|
|
|
subi r9,r3,1
|
|
|
li r3,0
|
|
|
- beq LStrlCompDone
|
|
|
+ beq .LStrlCompDone
|
|
|
mtctr r5
|
|
|
subi r4,r4,1
|
|
|
-LStrlCompLoop:
|
|
|
+.LStrlCompLoop:
|
|
|
{ load next chars }
|
|
|
lbzu r0,1(r9)
|
|
|
{ check if one is zero }
|
|
@@ -270,12 +270,12 @@ LStrlCompLoop:
|
|
|
{ calculate difference }
|
|
|
sub. r3,r0,r10
|
|
|
{ if chars not equal, we're ready }
|
|
|
- bne LStrlCompDone
|
|
|
+ bne .LStrlCompDone
|
|
|
{ if they are equal and one is zero, then the other one is zero too }
|
|
|
{ and we're done as well (r3 also contains 0 then) }
|
|
|
{ otherwise loop (if ctr <> 0) }
|
|
|
- bdnzf cr1*4+eq,LStrlCompLoop
|
|
|
-LStrlCompDone:
|
|
|
+ bdnzf cr1*4+eq,.LStrlCompLoop
|
|
|
+.LStrlCompDone:
|
|
|
end;
|
|
|
|
|
|
|
|
@@ -287,7 +287,7 @@ asm
|
|
|
{ use r28 instead of r3 for str1 since r3 contains result }
|
|
|
subi r28,r3,1
|
|
|
subi r4,r4,1
|
|
|
-LStriCompLoop:
|
|
|
+.LStriCompLoop:
|
|
|
{ load next chars }
|
|
|
lbzu r29,1(r28)
|
|
|
{ check if one is zero }
|
|
@@ -296,28 +296,28 @@ LStriCompLoop:
|
|
|
{ calculate difference }
|
|
|
sub. r3,r29,r30
|
|
|
{ if chars are equal, no further test is necessary }
|
|
|
- beq+ LStriCompEqual
|
|
|
+ beq+ .LStriCompEqual
|
|
|
|
|
|
{ make both lowercase, no branches }
|
|
|
li r27,0
|
|
|
li r25,0
|
|
|
|
|
|
{ r3 := r29 - 'A' }
|
|
|
- subic r3,r29,'A'
|
|
|
+ subic r3,r29,65
|
|
|
{ if r29 < 'A' then r27 := 0 else r27 := $ffffffff }
|
|
|
addme r27,r27
|
|
|
{ same for r30 }
|
|
|
- subic r3,r30,'A'
|
|
|
+ subic r3,r30,65
|
|
|
addme r25,r25
|
|
|
|
|
|
{ r3 := 'Z' - r29 }
|
|
|
- subfic r3,r29,'Z'
|
|
|
+ subfic r3,r29,90
|
|
|
{ if r29 < 'A' then r27 := 0 else r27 := $20 }
|
|
|
andi. r27,r27,0x020
|
|
|
{ if r29 > Z then r26 := 0 else r26 := $ffffffff }
|
|
|
subfe r26,r26,r26
|
|
|
{ same for r30 }
|
|
|
- subfic r3,r30,'Z'
|
|
|
+ subfic r3,r30,90
|
|
|
andi. r25,r25,0x020
|
|
|
subfe r24,r24,r24
|
|
|
|
|
@@ -333,13 +333,13 @@ LStriCompLoop:
|
|
|
|
|
|
{ compare again }
|
|
|
sub. r3,r29,r30
|
|
|
- bne LStriCompDone
|
|
|
-LStriCompEqual:
|
|
|
+ bne .LStriCompDone
|
|
|
+.LStriCompEqual:
|
|
|
{ if they are equal and one is zero, then the other one is zero too }
|
|
|
{ and we're done as well (r3 also contains 0 then) }
|
|
|
{ otherwise loop }
|
|
|
- bne cr1,LStriCompLoop
|
|
|
-LStriCompDone:
|
|
|
+ bne cr1,.LStriCompLoop
|
|
|
+.LStriCompDone:
|
|
|
end;
|
|
|
|
|
|
|
|
@@ -355,10 +355,10 @@ asm
|
|
|
cmplwi r5,0
|
|
|
subi r9,r3,1
|
|
|
li r3,0
|
|
|
- beq- LStrliCompDone
|
|
|
+ beq- .LStrliCompDone
|
|
|
mtctr r5
|
|
|
subi r4,r4,1
|
|
|
-LStrliCompLoop:
|
|
|
+.LStrliCompLoop:
|
|
|
{ load next chars }
|
|
|
lbzu r0,1(r9)
|
|
|
{ check if one is zero }
|
|
@@ -367,21 +367,21 @@ LStrliCompLoop:
|
|
|
{ calculate difference }
|
|
|
sub. r3,r0,r10
|
|
|
{ if chars are equal, no further test is necessary }
|
|
|
- beq LStrliCompEqual
|
|
|
+ beq .LStrliCompEqual
|
|
|
|
|
|
{ see stricomp for explanation }
|
|
|
li r8,0
|
|
|
li r5,0
|
|
|
|
|
|
- subic r3,r0,'A'
|
|
|
+ subic r3,r0,65
|
|
|
addme r8,r8
|
|
|
- subic r3,r10,'A'
|
|
|
+ subic r3,r10,65
|
|
|
addme r5,r5
|
|
|
|
|
|
- subfic r3,r0,'Z'
|
|
|
+ subfic r3,r0,90
|
|
|
andi. r8,r8,0x020
|
|
|
subfe r7,r7,r7
|
|
|
- subfic r3,r10,'Z'
|
|
|
+ subfic r3,r10,90
|
|
|
andi. r5,r5,0x020
|
|
|
subfe r24,r24,r24
|
|
|
|
|
@@ -392,13 +392,13 @@ LStrliCompLoop:
|
|
|
|
|
|
{ compare again }
|
|
|
sub. r3,r0,r10
|
|
|
- bne LStrliCompDone
|
|
|
-LStrliCompEqual:
|
|
|
+ bne .LStrliCompDone
|
|
|
+.LStrliCompEqual:
|
|
|
{ if they are equal and one is zero, then the other one is zero too }
|
|
|
{ and we're done as well (r3 also contains 0 then) }
|
|
|
{ otherwise loop (if ctr <> 0) }
|
|
|
- bdnzf cr1*4+eq,LStrliCompLoop
|
|
|
-LStrliCompDone:
|
|
|
+ bdnzf cr1*4+eq,.LStrliCompLoop
|
|
|
+.LStrliCompDone:
|
|
|
end;
|
|
|
|
|
|
|
|
@@ -408,16 +408,16 @@ asm
|
|
|
{ empty/invalid string? }
|
|
|
cmplwi r3,0
|
|
|
{ if yes, do nothing }
|
|
|
- beq LStrScanDone
|
|
|
+ beq .LStrScanDone
|
|
|
subi r3,r3,1
|
|
|
-LStrScanLoop:
|
|
|
+.LStrScanLoop:
|
|
|
lbzu r0,1(r3)
|
|
|
cmplwi r0,0
|
|
|
cmplw cr1,r0,r4
|
|
|
- bne LStrScanLoop
|
|
|
- beq cr1,LStrScanDone
|
|
|
+ bne .LStrScanLoop
|
|
|
+ beq cr1,.LStrScanDone
|
|
|
li r3, 0
|
|
|
-LStrScanDone:
|
|
|
+.LStrScanDone:
|
|
|
end;
|
|
|
|
|
|
|
|
@@ -427,21 +427,21 @@ asm
|
|
|
{ empty/invalid string? }
|
|
|
cmplwi r3,0
|
|
|
{ if yes, do nothing }
|
|
|
- beq LStrrScanDone
|
|
|
+ beq .LStrrScanDone
|
|
|
{ make r5 will be walking through the string }
|
|
|
subi r5,r3,1
|
|
|
{ assume not found }
|
|
|
li r3,0
|
|
|
-LStrrScanLoop:
|
|
|
+.LStrrScanLoop:
|
|
|
lbzu r10,1(r5)
|
|
|
cmplw cr1,r10,r4
|
|
|
cmplwi cr0,r10,0
|
|
|
- bne+ cr1,LStrrScanNotFound
|
|
|
+ bne+ cr1,.LStrrScanNotFound
|
|
|
{ store address of found position }
|
|
|
mr r3,r5
|
|
|
-LStrrScanNotFound:
|
|
|
- bne LStrrScanLoop
|
|
|
-LStrrScanDone:
|
|
|
+.LStrrScanNotFound:
|
|
|
+ bne .LStrrScanLoop
|
|
|
+.LStrrScanDone:
|
|
|
end;
|
|
|
|
|
|
|
|
@@ -449,20 +449,20 @@ end;
|
|
|
function strupper(p : pchar) : pchar;assembler;
|
|
|
asm
|
|
|
cmplwi r3,0
|
|
|
- beq LStrUpperNil
|
|
|
+ beq .LStrUpperNil
|
|
|
subi r9,r3,1
|
|
|
-LStrUpperLoop:
|
|
|
+.LStrUpperLoop:
|
|
|
lbzu r10,1(r9)
|
|
|
{ a <= x <= b <=> cardinal(x-a) <= cardinal(b-a) }
|
|
|
subi r0,r10,97
|
|
|
cmplwi r0,122-97
|
|
|
cmplwi cr1,r10,0
|
|
|
subi r10,r10,0x20
|
|
|
- bgt LStrUpper1
|
|
|
+ bgt .LStrUpper1
|
|
|
stb r10,0(r9)
|
|
|
-LStrUpper1:
|
|
|
- bne cr1,LStrUpperLoop
|
|
|
-LStrUpperNil:
|
|
|
+.LStrUpper1:
|
|
|
+ bne cr1,.LStrUpperLoop
|
|
|
+.LStrUpperNil:
|
|
|
end;
|
|
|
|
|
|
|
|
@@ -470,26 +470,31 @@ end;
|
|
|
function strlower(p : pchar) : pchar;assembler;
|
|
|
asm
|
|
|
cmplwi r3,0
|
|
|
- beq LStrLowerNil
|
|
|
+ beq .LStrLowerNil
|
|
|
subi r9,r3,1
|
|
|
-LStrLowerLoop:
|
|
|
+.LStrLowerLoop:
|
|
|
lbzu r10,1(r9)
|
|
|
{ a <= x <= b <=> cardinal(x-a) <= cardinal(b-a) }
|
|
|
subi r0,r10,65
|
|
|
cmplwi r0,90-65
|
|
|
cmplwi cr1,r10,0
|
|
|
addi r10,r10,0x20
|
|
|
- bgt LStrLower1
|
|
|
+ bgt .LStrLower1
|
|
|
stb r10,0(r9)
|
|
|
-LStrLower1:
|
|
|
- bne cr1,LStrLowerLoop
|
|
|
-LStrLowerNil:
|
|
|
+.LStrLower1:
|
|
|
+ bne cr1,.LStrLowerLoop
|
|
|
+.LStrLowerNil:
|
|
|
end;
|
|
|
|
|
|
|
|
|
{
|
|
|
$Log$
|
|
|
- Revision 1.21 2003-08-24 20:51:27 olle
|
|
|
+ Revision 1.22 2003-11-29 16:27:19 jonas
|
|
|
+ * fixed several ppc assembler reader related problems
|
|
|
+ * local vars in assembler procedures now start at offset 4
|
|
|
+ * fixed second_int_to_bool (apparently an integer can be in LOC_JUMP??)
|
|
|
+
|
|
|
+ Revision 1.21 2003/08/24 20:51:27 olle
|
|
|
+ added MacOS compatible constant loading
|
|
|
|
|
|
Revision 1.20 2003/07/07 20:23:46 peter
|