Thread View: borland.public.delphi.basm
2 messages
2 total messages
Started by Kartal Turgut
Tue, 27 Aug 2002 09:24
String compare and store
Author: Kartal Turgut
Date: Tue, 27 Aug 2002 09:24
Date: Tue, 27 Aug 2002 09:24
58 lines
2378 bytes
2378 bytes
I'm still trouble on strings. I wanna compare two strings. I try it but
i couldn't.
I'm trying to find string to another which is sperated with commas.
CheckModulDepend('Table1', 'Table0,Table1,Table2');
Result = 1
CheckModulDepend('Table1', 'Table0,Table2');
Result = 0
function CheckModulDepend( Modul, Depend: STRING): Integer; Assembler;
asm
PUSH EBX
PUSH EDI
PUSH ESI
MOV ESI, EAX // (MODUL)
MOV EAX, EDX //(DEPEND)
MOV EDX, ESI //(MODUL)
CMP EAX, ESI //first compare Modul and Depend
JE @@EQUEL //if equel go @@EQUEL
MOV ECX, [EAX-4] //Depend string length
@@CHECK:
MOV BL, [EAX] //move Depend char to BL
INC EAX // increment register
CMP BL, $2C //check if BL is COMMA
JE @@CHECKEQUEL
MOV [EDI], BL //store BL to EDI
INC EDI
JMP @@SKIPCHECK
@@CHECKEQUEL:
CMP EDI, EDX //Compare EDI and EDX(MODUL)
JE @@EQUEL
@@SKIPCHECK:
DEC ECX
JNZ @@CHECK
XOR EAX,EAX
MOV EAX, 0 //if not equel then result = 0
JMP @END
@@EQUEL:
XOR EAX,EAX
MOV EAX, 1 // if equel Result = 1
@END:
POP ESI
POP EDI
POP EBX
end;
thanks for any help.
Kartal Turgut
Re: String compare and store
Author: Andrew Rybenkov
Date: Tue, 27 Aug 2002 19:41
Date: Tue, 27 Aug 2002 19:41
33 lines
1973 bytes
1973 bytes
Kartal, do you need biggest speed in your matter? From your example I assumed you need to parse something of command line, - no light speed needed in the case. :) But if you want to write fastest general substring search routine - well, use other algorithm(s) search Google for "Boyer-Moore", or find books by Niklaus Wirth- such as "Algorithms and Data Structure" BTW, > XOR EAX,EAX > MOV EAX, 0 > JMP @END > @@EQUEL: > XOR EAX,EAX > MOV EAX, 1 // if equel Result = 1 > @END: you can safely replace for > XOR EAX,EAX //if not equel then result = 0 > JMP @END > @@EQUEL: > MOV EAX, 1 // if equel Result = 1 > @END: -- Andrew Rybenkov. create labels, logos, image lists for your programs and websites with "Imagizer: Click and Get It", http://www.geocities.com/arybenkov/imagizer/
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads