News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

64 bit variables

Started by zedd151, October 20, 2024, 02:33:34 PM

Previous topic - Next topic

zedd151

Why does this not work: ?
mov var, 7FFFFFFFFFFFFFFDh
Quoteerror A2084:constant value too large

But this does work: ???
mov rax, 7FFFFFFFFFFFFFFDh
mov var, rax

In both cases 'var' is a qword variable. Using ml64 to assemble.

:rolleyes:  :tongue:  :undecided:  :smiley:

sinsi

Pretty sure that mov mem,imm is restricted to a 32-bit value only.

zedd151

Quote from: sinsi on October 20, 2024, 03:02:58 PMPretty sure that mov mem,imm is restricted to a 32-bit value only.
Really? Even for qwords in 64 bit code?? That's rather odd.  :sad:
It seems I ought to do some more research.  ... ... grumble, grumble.

Okay, thanks.

sinsi

According to the Intel docs, the only mov is MOV r64,imm64, there's no equivalent MOV r/m64,imm64  :sad:

Quote from: sinsi on October 20, 2024, 03:02:58 PMrestricted to a 32-bit value only
Of course I meant "restricted to a maximum 32-bit value only"  :biggrin:

zedd151

Yes, I was just now finding this out... and the reasons why.   :smiley:
Makes me want to stick to 32 bit.   :tongue:



sinsi

Quote from: zedd151 on October 20, 2024, 03:29:35 PMYes, I was just now finding this out... and the reasons why.   :smiley:
Makes me want to stick to 32 bit.   :tongue:
One little thing like that? You wuss :badgrin:

zedd151

:biggrin:
What good are 64 bit variables if I cannot use them to their full potential?   :biggrin:

Anyway I have converted "dwtoa" from the masm32 library to "qwtoa" for use in 64 bit code. I was testing that function when I came across this issue.

So far "qwtoa" is working as expected, it converts signed qword values to ascii decimal string. Will post it when my testing is finished.

NoCforMe

Quote from: sinsi on October 20, 2024, 03:02:58 PMPretty sure that mov mem,imm is restricted to a 32-bit value only.

Is that an Intel restriction or an assembler one?

According to Felix Cloutier, the largest valid MOV of an immediate value to memory uses a 32-bit value (which can be sign-extended to 64 bits).
Assembly language programming should be fun. That's why I do it.

zedd151

It's a limitation of the ISA. (Intel/AMD)
We are actually running an x86 in 64 bit mode, if I correctly understood what I have read just a little while ago.

x86_64 This is not where I read about it, but explains some of the details.

sinsi

Quote from: NoCforMe on October 20, 2024, 04:06:50 PM
Quote from: sinsi on October 20, 2024, 03:02:58 PMPretty sure that mov mem,imm is restricted to a 32-bit value only.

Is that an Intel restriction or an assembler one?
It's a limitation of the CPU, there's no encoding for it.

sinsi

Quote from: zedd151 on October 20, 2024, 04:13:28 PMWe are actually running an x86 in 64 bit mode
32-bit code runs in compatibility mode under long mode if that makes sense :biggrin:

zedd151

Now I am totally confused. There seems to be a lot of conflicting information around, or maybe I simply don't understand it.    :smiley:

daydreamer

Write 64 bit version of m2m macro as solution ?
It short for memory2memory
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

NoCforMe

Nah: just do
  MOV  [register], [64-bit value]
  MOV  [memory], [register]
Assembly language programming should be fun. That's why I do it.

zedd151

The only good thing about this, is that Microsoft is off the hook for this oddity.   :biggrin:
64 bit CPU (but only sometimes).   :badgrin: