News:

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

Direct Operands

Started by redskull, October 16, 2009, 12:18:03 PM

Previous topic - Next topic

redskull

Hey everyone-

Is there anyway to get MASM to assemble a direct, numerical memory offset?  For example:

EAX, DWORD PTR [00402000h]

always assembles as the immediete:

B8 00204000 - MOV EAX, 00402000

The only way to get MASM to do it is via the indirect access.  I know it would have little real-world use, but to assemble a memory move as an immediete move, and not at least give a warning or something seems backwards.

-r
Strange women, lying in ponds, distributing swords, is no basis for a system of government

dedndave

well - there are a couple ways that i have used
one is to create a label

        org     402000h
SomeDword LABEL DWORD
.
.
.
        mov     eax,SomeDword

another way is to hard-code it

        db      0B8h      ;mov eax,[aaaaaaaa]
        dd      402000h   ;address

japheth


> another way is to hard-code it

>        db      0B8h      ;mov eax,[aaaaaaaa]
>        dd      402000h   ;address

Very ugly!

The correct thing is to use a segment register prefix:

    mov EAX, DWORD PTR ds:[00402000h]


redskull

Quote from: japheth on October 16, 2009, 01:22:38 PM
The correct thing is to use a segment register prefix:

    mov EAX, DWORD PTR ds:[00402000h]

Bingo, much obliged.  More and more I find some of the logic behind MASM syntax completely bizarre.

thanks again

-r
Strange women, lying in ponds, distributing swords, is no basis for a system of government

dedndave

ahhhhh - so THAT's the secret - lol
damnasm.exe

although "DWORD PTR" should not be required - "eax," forces that

        mov     eax,ds:[402000h]