Here's my dilemma:
I'm trying to pass the address of a byte buffer to a procedure using INVOKE to allow the procedure to make modifications to some bytes in the buffer space. I can't seem to access the individual bytes in the buffer inside the procedure, which leads me to believe that I'm passing it incorrectly.
The problem is that when I try to move a byte from the buffer into the AL register, I get a size mis-match error at the line indicated below (inside the function)
I'm not including all my code but here are the pertinent parts:
;Definition of the Buffer
inputBuf BYTE ByteCount DUP(0)
;Declaration of the Procedure
replaceCR PROTO, buffer:PTR BYTE, bRead:DWORD
;Call to the Procedure (INVOKE)
INVOKE replaceCR, addr inputBuf, bytesRead
;The Procedure
replaceCR PROC buffer:PTR BYTE, bread:DWORD
mov ecx, 0
mov al,buffer[ecx] ;;ERROR occurs here and other places below
loopA:
.if al == 0dh
mov buffer[ecx], 20h
.endif
inc ecx
mov al, buffer[ecx]
cmp ecx, bread
jbe loopA
ret
replaceCR ENDP
My question is How do I correctly pass the address of the buffer and if I'm doing it correctly, why do I get an error at that point?
Thanks for any help.
Hi riversr54
You are passing the address of the byte array correctly.
Your problem is here
mov al,buffer[ecx]
buffer is a POINTER, so you have to use indirection
mov edx, buffer
mov al, BYTE ptr [edx + ecx]
Biterider
So, if I'm understanding you...I can't do the indirection directly on a Pointer, it has to be done on a register value?
Bottom line, it works!!!
Thanks very much.