News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Memory and byte ptr

Started by georgek01, September 01, 2011, 03:54:12 PM

Previous topic - Next topic

georgek01

Good day,

I would like to access individual bytes from a memory buffer created with GlobalAlloc, similar to:

mov al, byte ptr szBuffer[esi]



...

invoke GlobalAlloc,GMEM_FIXED,dwRead
mov hMem,eax

invoke GlobalLock,hMem
mov pMem,eax

...

invoke GlobalSize,hMem
mov ecx,eax

invoke InternetReadFile,hSession,pMem,ecx,addr dwRead

mov al, byte ptr pMem[esi] ; --- this does not work.

.if al == '<'

...



Your assistance will be greatly appreciated!

Regards,
George
What we have to learn to do, we learn by doing.

- ARISTOTLE (384-322 BC)

tenkey

Load the "base" pointer into a register. All of the variable components of an address must be in registers.

mov ecx,pMem  ; GlobalAlloc gave us a pointer - load it
mov al, byte ptr[ecx+esi]
A programming language is low level when its programs require attention to the irrelevant.
Alan Perlis, Epigram #8

dedndave

...

mov eax,dwRead
mov dwAllocSize,eax                      ;save the allocation size
invoke GlobalAlloc,GMEM_FIXED,eax
mov hMem,eax

invoke GlobalLock,hMem
mov pMem,eax

...

invoke InternetReadFile,hSession,pMem,dwAllocSize,addr dwRead

mov edx,pMem
mov al,[edx]                             ;"byte ptr" not required
mov cl,[edx+5]                           ;example of a fixed index

.if al == '<'

...

georgek01

Thank you! Both those answered my question.
What we have to learn to do, we learn by doing.

- ARISTOTLE (384-322 BC)