Vote count:
0
i am working on assembly project and i am trying some string operations. Problem that i encountered is with SCAS function. I am trying to search my text for specific string occurence or even substring occurence. I thought SCAS might fit this task. What i found about Scas is Basically this:
The example there shows how a simple character can be found in a buffer. Thats nice and i can use it because i read my text file using buffer so i can search this buffer multiple times to find occurence of my string. Problem is that i can figure out the way how can i use custom strings instead of characters with SCAS.
In my code i am trying something like this
CYK:
CMP pomaxx,0
JZ NACITAJ2
DEC pomaxx
MOV CX,BUFSIZ
MOV DX,OFFSET buff
MOV AH,3Fh
INT 21h
MOV AX, DS
MOV ES, AX ;SCAS uses ES:DI, so copy DS to ES
CLD ;Scan in the forward direction
MOV AL, STRI
MOV CX,BUFSIZ ;Scanning 50 words (CX is used by REPNE)
LEA DI, buff ;Starting address to DI
REPNE SCAS buff ; ...and scan it.
JE FOUND ;The Zero Flag will be set if we found
; a match.
NOTFOUND: JMP CYK ;If we get here, no match was found
FOUND:
MOV SI,OFFSET buff ;DS:SI musi ukazovat na miesto z ktoreho chceme tahat
CYKBUFSIZ2:
LODSB
PCHAR AL
LOOP CYKBUFSIZ2
JMP PRVY2
The last cycle is just generating output. So in this code i am trying to walk through my text fuile and buffer by buffer search my string and if i find the string i print the whole buffer. The STRI variable is defined as follows: STRI DB STRSIZ DUP(?). There i have my string i would like to find in my text file.
Can anyone help what am i doing wrong? Thx
ASM SCAS - find a String except of character in buffer
Aucun commentaire:
Enregistrer un commentaire