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.

???

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.

a million thank you to you sDJh!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.