The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Valerón on June 11, 2010, 07:36:54 AM

Title: [MASM syntax question]How to assemble hard coded address value in mov?
Post by: Valerón on June 11, 2010, 07:36:54 AM
Hi, folks.
I'm not newbie to assembly. I've been working in assembly for years.
This is a question about the syntax of MASM. Recently I work with MSVC, so it is the assembler in hand.

I need to assembler this instruction
mov eax, [0x89abcdef]
I don't want the hard coded 0x89abcdef act as  an immediate value but a pointer.
I don't know how to do it in MASM. MASM seems to lack of convenient syntax to hard code pointer value(I don't know how to assemble far jmp and far call as well), at least I don't know yet.
I know I can employee db(or _emit in C++) to hard code the whole instruction, but that make the code less readable.

Thank you.
Title: Re: [MASM syntax question]How to assemble hard coded address value in mov?
Post by: jj2007 on June 11, 2010, 07:49:42 AM
include \masm32\include\masm32rt.inc

.data
MyVal dd 12345678h

.code
start:
mov eax, ds:[0402000h]
exit

end start


Now it's your turn to explain why you want to hardcode an address...
Title: Re: [MASM syntax question]How to assemble hard coded address value in mov?
Post by: Valerón on June 11, 2010, 08:02:17 AM
Thank you.
Frankly I'm going to patch something. To help analyze a protocol.

Wait... the problem hasn't been solved yet.

mov eax, ds:[0x12345678] is assembled to a "far" move with the segment register in mind.

Is there any method to assemble without segment register?
Title: Re: [MASM syntax question]How to assemble hard coded address value in mov?
Post by: BogdanOntanu on June 11, 2010, 08:40:55 AM
Warning: No "patching" and reversing / analyzing of "protocols" is allowed in here  :green