ThunderForest
IS-IT--Management
I'm responsible for an application that made ample, and extensive use of HyperStr, a 3rd party string library that apparently was no longer supported or upgraded following Delphi 5. Google turns up dead ends on the author. I need to upgrade the application to v7 for other reasons, but it crashes during the compile in Hyperstr.Pas (see below), Operand Size Mismatch in Delphi 7. No problem with Delphi 5. It will crash at every occurence of the "Bt" line. The values in that line are apparently not equal, but I don't know why. Unfortunately, my assembler background is quite limited. I could easily write my own string functions, but the application is rather massive and really took advantage of what HyperStr had to offer, that is, assembler. Before I begin pounding out code, anyone experience this and have any ideas? Thanks.
begin
UniqueString(Source); //start with a unique string
asm
Push EBX //save the important stuff
Push ESI
Push EDI
Push EBP
Mov EAX,Source // Copy Source to EAX
Or EAX,EAX
Jz @Exit
Mov EAX,[EAX]
Mov EDX,Table
Mov ECX,Index
Call _TableScanIni // Procedure
Jecxz @Abort
Push ECX // save length
Sub ECX,EAX
Mov EBX,ESI // use EBX as write pointer
Xor EAX,EAX
@Next:
Lodsb //Load source into AL
Mov DL,AL //save it in DL
Mov DH,DL //and in DH
And DL,31 //bit index - doubleword is 31
Shr EAX,5 //dbl-word index
Shl EAX,2
Mov EBP,[EDI+EAX] //get the dbl-word
//CRASH OCCURS AT NEXT LINE
Bt EBP,DL //Bit Test
Jc @Skip //skip write if in Table
Mov [EBX],DH
Inc EBX
@Skip:
Dec ECX
Jnz @Next
Pop EAX //original source length
Mov DH,32 //prepare to space fill
@L3:
Cmp EBX,ESI //read = write ?
Jz @Exit //yes, then we're done
Mov [EBX],DH //no, then space fill
Inc EBX
Dec EAX //adjust output length
Jmp @L3 //and do it again
@Abort:
Xor EAX,EAX
@Exit:
Pop EBP //restore the world
Pop EDI
Pop ESI
Pop EBX
Mov Result,EAX //output length
end;
end;
Getting answers before I'm asked.
Providing answers if I can.
begin
UniqueString(Source); //start with a unique string
asm
Push EBX //save the important stuff
Push ESI
Push EDI
Push EBP
Mov EAX,Source // Copy Source to EAX
Or EAX,EAX
Jz @Exit
Mov EAX,[EAX]
Mov EDX,Table
Mov ECX,Index
Call _TableScanIni // Procedure
Jecxz @Abort
Push ECX // save length
Sub ECX,EAX
Mov EBX,ESI // use EBX as write pointer
Xor EAX,EAX
@Next:
Lodsb //Load source into AL
Mov DL,AL //save it in DL
Mov DH,DL //and in DH
And DL,31 //bit index - doubleword is 31
Shr EAX,5 //dbl-word index
Shl EAX,2
Mov EBP,[EDI+EAX] //get the dbl-word
//CRASH OCCURS AT NEXT LINE
Bt EBP,DL //Bit Test
Jc @Skip //skip write if in Table
Mov [EBX],DH
Inc EBX
@Skip:
Dec ECX
Jnz @Next
Pop EAX //original source length
Mov DH,32 //prepare to space fill
@L3:
Cmp EBX,ESI //read = write ?
Jz @Exit //yes, then we're done
Mov [EBX],DH //no, then space fill
Inc EBX
Dec EAX //adjust output length
Jmp @L3 //and do it again
@Abort:
Xor EAX,EAX
@Exit:
Pop EBP //restore the world
Pop EDI
Pop ESI
Pop EBX
Mov Result,EAX //output length
end;
end;
Getting answers before I'm asked.
Providing answers if I can.