The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: korte on March 18, 2007, 04:05:56 PM

Title: struct assume problem
Post by: korte on March 18, 2007, 04:05:56 PM
My code:


WINDOW   STRUCT
_WINDOW_Flag      DD   ?
_WINDOW_CLASS     DD   ?
_WINDOW_X      DD   ?
_WINDOW_Y      DD   ?
_WINDOW_WIDTH      DD   ?
_WINDOW_HEIGHT      DD   ?
_WINDOW_PROC             DD      ?
_WINDOW_VALUE      DD   ?
_WINDOW_PARRENT   DD   ?
WINDOW ENDS


.
.
.

error this line:
    assume esi: PTR WINDOW

error code: type is wrong size for register

writing this "assume si: PTR WINDOW" no error






Title: Re: struct assume problem
Post by: Vortex on March 18, 2007, 05:49:14 PM
I don't see any problem with the ASSUME statement :

.386
.model flat,stdcall
option casemap:none

WINDOW  STRUCT

    _WINDOW_Flag    DD  ?
    _WINDOW_CLASS   DD  ?
    _WINDOW_X       DD  ?
    _WINDOW_Y       DD  ?
    _WINDOW_WIDTH   DD  ?
    _WINDOW_HEIGHT  DD  ?
    _WINDOW_PROC    DD  ?
    _WINDOW_VALUE   DD  ?
    _WINDOW_PARRENT DD  ?

WINDOW  ENDS

.data?

buffer  db 100 dup(?)

.code

start:

    mov     esi,OFFSET buffer
    ASSUME  esi:PTR WINDOW
    mov     [esi]._WINDOW_X,100
    ASSUME  esi:NOTHING
    ret

END start
Title: Re: struct assume problem
Post by: u on March 18, 2007, 08:57:22 PM
it's probably because his
".model flat,stdcall" isn't present or intact.
(note that the assembler assumes a pointer to be 16-bit, not 32-bit)
Title: Re: struct assume problem
Post by: korte on March 18, 2007, 10:10:11 PM


thanx.

Problem 16 bit segment.


xcode segment para public 'CODE' use16




Title: Re: struct assume problem
Post by: MichaelW on March 18, 2007, 10:58:10 PM
In a 16-bit segment you need to use a 16-bit register for the pointer, and it must be a base or index register. If you combine two registers in one instruction, one must be a base register and the other an index register. For example:

mov ax,[bx+si]

is OK, but these are not:

mov ax,[bp+bx]
mov ax,[si+di]