Hello everyone, I've been busy working with school and doing some projects but I have stumbled across a roadblock. I'm using MASM v7 I think.

I'm having problems with the assume directive, lets say I have a pointer to a struct called BLOCK

BLOCK struct
item1 dd 0
item2 dd 0
item3 dd 0
BLOCK ends

Lets say I want to let MASM32 know that ESI holds a pointer to a BLOCK structure, this is how I did it:

assume esi:PTR BLOCK

Now how would I access the different items in the structure ? I think BitRake told me but I forgot (sorry buddy :-(, please don't flame me )

Thanks for your help
Posted on 2003-01-31 15:42:51 by x86asm
.item1 :tongue:
Posted on 2003-01-31 16:50:50 by bitRAKE

.item1 :tongue:

I tried that but it says undefined symbol! me confused!! :confused:
Posted on 2003-01-31 17:42:26 by x86asm

I tried that but it says undefined symbol! me confused!! :confused:

That is strange. Maybe another ASSUME overrides the previous one?

If ASSUME does not work for you, you can always fall back to 'full' reference to members, like,


This works even if esi is assumed to be something else.
Posted on 2003-01-31 18:38:27 by Starless
The ASSUME directive used with either a segment register or a data register will NOT change the value of that register.

In your example, if you want ESI to point to your STRUC, use:
lea esi,BLOCK or
mov esi, offset BLOCK

Then, and only then, ESI will point to the STRUC and you can then refer to individual items as suggested.

(You will rarely ever have to use the ASSUME directive in 32-bit assembler. It used to be a necessity in 16-bit assembler for the segment registers. Using the ASSUME directive with data registers can only lead to confusion, possible errors and/or extra typing; use the byte/word/dword/qword PTR directive instead.)

Posted on 2003-01-31 22:02:58 by Raymond
Here is my favorite MASM assume command:
Posted on 2003-01-31 22:52:41 by bitRAKE

Here is a small example:

.model flat,stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib


member struct
_name dword ?
location dword ?
posts dword ?
member ends

m1 db 'x86asm',13,10,0
m2 db 'Toronto',0

coder member <?>

mov esi,offset coder
assume esi:ptr member
mov eax,offset m1
mov ebx,offset m2
mov dword ptr [esi]._name,eax
mov dword ptr [esi].location,ebx
mov dword ptr [esi].posts,282
invoke StdOut,coder._name
invoke StdOut,coder.location
assume esi:nothing
invoke ExitProcess,0
end start

Posted on 2003-02-01 03:49:09 by Vortex
I was just curious to know why one would insist on using a register such as ESI to reference STRUC members when you can do it directly such as:

mov coder._name,eax

which, in my opinion, would make the code much easier to understand as compared to loading an "anonymous" register as a pointer. The register pointer also introduces a few more lines of code which could possibly be avoided.

bitRAKE probably has the best example of the use of the ASSUME directive.

Posted on 2003-02-01 11:26:14 by Raymond
Raymond, in dynamic situations you must use a pointer. It is less typing to use ASSUME, but it is also less clear and less cut-n-paste'able. I like using the method Starless posted.
Posted on 2003-02-01 13:05:02 by bitRAKE
Thanks for your help!! I will try it ! :)
Posted on 2003-02-01 21:08:11 by x86asm