The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: rags on February 26, 2012, 03:19:32 PM

Title: Jwasm constant question
Post by: rags on February 26, 2012, 03:19:32 PM
I'm playing around with jwasm v2.07pre, Nov  2 2011 in 64 bit mode and keep getting an error.
The error I'm getting is:
mytest.asm(37) : Error A2235: Constant value too large: 6E6972747320796Dh

the offending code is:

.data
count       dq      0
.code
......
lea rax, count
mov qword ptr[rax], 06E6972747320796Dh

I can move the constant directly into the register with no problem, but when I try to mov
it into memory by reference it errors.
Am I missing something simple, or can someone using jwasm check it for me to see if its
a bug in jwasm?
Title: Re: Jwasm constant question
Post by: qWord on February 26, 2012, 05:08:57 PM
In  x64, immediate values are also limit to 32 Bit. The only exception is MOV, which allows to move 64 Bit values to registers:
mov rdx,06E6972747320796Dh
mov [rax],rdx
Title: Re: Jwasm constant question
Post by: rags on February 26, 2012, 05:51:06 PM
Thanks qword.
Title: Re: Jwasm constant question
Post by: MichaelW on February 26, 2012, 07:02:55 PM
Can't you also do it this way (works with the 32-bit versions of MASM)?

count dq 06E6972747320796Dh

Title: Re: Jwasm constant question
Post by: rags on February 26, 2012, 09:19:29 PM
Yes Michael that also works.
I was working on a compile time macro that would store different 64bit values
to a memory location by reference, depending on what values were passed to the macro.
One of the parameters was the address of the location to store the value.
I was unaware of the limitations to immediate values involved, and couldn't figure out what was causing that error,
So I was using that code I posted to try and see what was going wrong.
The line in the code that was causing me headaches was:

mymacro macro param1:req, param2:req
         ; param1 is an address of a buffer
         ; param2 is text
         ; StrIn is the converted text
         ; ??i is the character count
         ; -------------
         local StrIn, ??i
         ; do something with param2 to convert it into a 64 bit values
         mov qword ptr StrVar[(??i and -8)], StrIn      ;<----------This was the problem line
         ; do some more work
endm

Since StrIn was a 64 bit value, and the destination address was a 64 bit location, I was having a
hard time understanding why it wouldnt work, until it was pointed out by qword about the size limitations
of immediate values.
One would think that if working in the 64 bit mode, 64 bit sized immediate values would be allowed.