Hi Gurus,
I have a small script below that report an error when I compile it
I could not regconise what's wrong with me
any reply are welcome
Thanks
nvm
......
invoke GetFileSize,hFile, NULL
mov MemSize,eax ; get file size before allocate memery for it

invoke GlobalAlloc,GMEM_MOVEABLE or GMEM_ZEROINIT, MemSize
mov hMemory,eax ; allocate amount of memmory equal to file size

invoke GlobalLock,hMemory
mov pMemory,eax ; lock the memory area

; mapping the file content into memory
invoke ReadFile,hFile,pMemory,MEMSIZE,ADDR SizeReadWrite,NULL

;prepare registers for use as index counter

xor ebx, ebx
xor ecx, ecx

@myloop:
cmp ecx, MEMSIZE
je @@done

mov dl,

;I face the problem at this point A2009 syntax error in expression
;my purpuse is to move one byte from the pMemory address into dl register in order to make comparison
;I also try move dl, BYTE but the problem is same
..............
Posted on 2004-01-12 05:59:35 by nvm

Hi Gurus,
I have a small script below that report an error when I compile it
I could not regconise what's wrong with me
any reply are welcome
Thanks
nvm
......
invoke GetFileSize,hFile, NULL
mov MemSize,eax ; get file size before allocate memery for it

invoke GlobalAlloc,GMEM_MOVEABLE or GMEM_ZEROINIT, MemSize
mov hMemory,eax ; allocate amount of memmory equal to file size

invoke GlobalLock,hMemory
mov pMemory,eax ; lock the memory area

; mapping the file content into memory
invoke ReadFile,hFile,pMemory,MEMSIZE,ADDR SizeReadWrite,NULL

;prepare registers for use as index counter

xor ebx, ebx
xor ecx, ecx

@myloop:
cmp ecx, MEMSIZE
je @@done

mov dl,

;I face the problem at this point A2009 syntax error in expression
;my purpuse is to move one byte from the pMemory address into dl register in order to make comparison
;I also try move dl, BYTE but the problem is same
..............


Maybe with this :

mov dl, byte ptr
Posted on 2004-01-12 06:04:28 by Eternal Idol Birmingham
mov dl,
There is no direct coding of such an instruction. You will have to replace it with something similar to the following:
mov edx,pMemory

add edx,ecx
mov dl,[edx]

Or, if you have some other free register (such as ESI), you could initialize it to pMemory before your loop and then use the following:
mov dl,[esi]

inc esi
Raymond
Posted on 2004-01-12 12:03:49 by Raymond
mov dl, byte ptr [pMemory + ecx]

Is a perfectly fine addressing mode, it would encode as (given an offset of 402000 for pMemory):

8A 91 00 20 40 00 > mov dl, BYTE PTR

There is no need for a separate register for this addressing mode. MASM's parser may require that ecx is placed first, I have not tested it.

EDIT: Quick check and MASM 7.10.3077 encodes it properly as shown. The problem was the lack of a byte ptr, MASM's type checker throws an error.
Posted on 2004-01-12 12:11:40 by donkey
I only tested if it assembles and I didn't get any error, so I posted that code.

I think that it will work perfectly with mov dl, byte ptr as I said before.
Posted on 2004-01-12 12:25:37 by Eternal Idol Birmingham
Well, it wouldn't do anything good.
This would be more useful:
mov edx,pMemory
mov dl,
Posted on 2004-01-12 12:43:06 by Sephiroth3
Yes you're right. I didn't look at the whole code, you need a register for indirect addressing of that type as he wants to use the value in pMemory not the offset of the variable. That is not defined at compile time.
Posted on 2004-01-12 12:51:38 by donkey
Hello Gurus,
All of the answers are valueable for me
Thank you very much
nvm
Posted on 2004-01-12 19:43:18 by nvm