0

Is there anyone who knows how to locate the file pointer and display its value? I am currently doing an assembly program that searches for a string in a given file and returns its offset from the beginning of the file. For example, the display would be "string found at offset 001eh". I'm not sure though how to calculate something like 001eh but my project requirements is that. Thank you very much in advance.

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by niernier
0

???

When you access and search through a file you need a pointer anyway.

MOV AL,[file+EBX]

So write a routine that compares a string and a string (file) with an offset.

;ESI: string1
;EDI: string2
PUSH EBX
MOV ECX,string1length
cmp_loop:
MOV AL,[ESI+EBX]
MOV AH,[EDI+EDX]
CMP AL,AH
JNE cmp_false
LOOP cmploop
STC
POP BEX
RET
cmp_false:
CLC
POP EBX
RET

(This code returns CF=1, when the string occured)

If the string occured in the file, then you just can print the pointer (in my case EBX).

That should be all.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.