howto: MOV EAX, <64bit value> ?

  • Follow


Hello Newsgroup,

how can I store a 64 bit value in a EAX register for
686 or below x86 32bit amd pc architectures?

..8087
..386
..model flat
..code

; value = 4614253070214989087 // <-- this is it

Entry:
mov eax, <value>
fld tbyte ptr [ebx]
ret

end Entry
; EOF

thanks for helping
Jens 

0
Reply Jens 6/14/2008 4:09:01 PM

"Jens Kallup"  <spamtrap@crayne.org> writes:

> how can I store a 64 bit value in a EAX register for
> 686 or below x86 32bit amd pc architectures?

Hi.

You should read some documentation. EAX is a 32-bit register. you
can't use it to store a 64-bit value. Only the lower/upper part of it.

If you tell us what you want to do, maybe we can help you better :-)

-- 

  - Filipe Cabecinhas

(defvar real-email
  (apply #'concatenate 'string
         '("filcab" "@" "gmail" "." "com"))
  "My real email address.")

0
Reply Filipe 6/14/2008 7:25:03 PM


On Jun 14, 9:09 am, "Jens Kallup"  <spamt...@crayne.org> wrote:
> Hello Newsgroup,
>
> how can I store a 64 bit value in a EAX register for
> 686 or below x86 32bit amd pc architectures?
>
> .8087
> .386
> .model flat
> .code
>
> ; value = 4614253070214989087 // <-- this is it
>
> Entry:
> mov eax, <value>
> fld tbyte ptr [ebx]
> ret
>
> end Entry
> ; EOF
>
> thanks for helping
> Jens

There's no magic, you can't fit an arbitrary 64-bit number into 32
bits of a register. You can store the halves of a 64-bit number in 2
32-bit registers, however.

Alex

0
Reply Alexei 6/14/2008 8:27:37 PM

"Jens Kallup"  <spamtrap@crayne.org> writes:
> Hello Newsgroup,
>
> how can I store a 64 bit value in a EAX register for
> 686 or below x86 32bit amd pc architectures?

You can't. You can't fit 16-bit values in an 8-bit 
register or 32-bit values in a 16-bit register, so 
why did you think you could fit a 64-bit value into
a 32-bit register?

> .8087
> .386
> .model flat
> .code
>
> ; value = 4614253070214989087 // <-- this is it
>
> Entry:
> mov eax, <value>
> fld tbyte ptr [ebx]

Why do you include that in your example? Are you trying
to load a 64-bit (signed) integer value into a FP register
instead? In which case, there is an *integer load* instruction
in the FPU instruction set for that purpose.

Phil
-- 
Dear aunt, let's set so double the killer delete select all.
-- Microsoft voice recognition live demonstration

0
Reply Phil 6/14/2008 8:30:47 PM

On Sat, 14 Jun 2008 18:09:01 +0200
"Jens Kallup"  <spamtrap@crayne.org> wrote:

> how can I store a 64 bit value in a EAX register

It is not physically possible to store a 64 bit value in a 32 bit
register.

-- 
Chuck 
http://www.pacificsites.com/~ccrayne/charles.html

0
Reply Charles 6/14/2008 9:04:25 PM

Jens Kallup wrote:
> Hello Newsgroup,
> 
> how can I store a 64 bit value in a EAX register for
> 686 or below x86 32bit amd pc architectures?

Shoehorn! :)

> .8087
> .386
> .model flat
> .code
> 
> ; value = 4614253070214989087 // <-- this is it
> 
> Entry:
> mov eax, <value>
> fld tbyte ptr [ebx]
> ret
> 
> end Entry
> ; EOF

What you *can* do is store a pointer to a 64 bit number (a 32-bit 
pointer, of course!) in eax. Did you mean to use both eax and ebx above?

mov eax, offset value
fld qword ptr [eax]

Maybe? (tword is 80 bits, though - maybe this isn't what you want)

Or you could...

mov eax, dword ptr value
mov edx, dword ptr value + 4

and have the 64-bit value in edx:eax.

But 64 into 32 don't go.

Best,
Frank

0
Reply Frank 6/14/2008 11:25:45 PM

Frank Kotler  <spamtrap@crayne.org> writes:
> Jens Kallup wrote:
>> Hello Newsgroup,
>>
>> how can I store a 64 bit value in a EAX register for
>> 686 or below x86 32bit amd pc architectures?
>
> Shoehorn! :)
>
>> .8087
>> .386
>> .model flat
>> .code
>>
>> ; value = 4614253070214989087 // <-- this is it
>>
>> Entry:
>> mov eax, <value>
>> fld tbyte ptr [ebx]
>> ret
>>
>> end Entry
>> ; EOF
>
> What you *can* do is store a pointer to a 64 bit number (a 32-bit
> pointer, of course!) in eax. Did you mean to use both eax and ebx
> above?
>
> mov eax, offset value
> fld qword ptr [eax]

fld or fild - depending on value.

Phil
-- 
Dear aunt, let's set so double the killer delete select all.
-- Microsoft voice recognition live demonstration

0
Reply Phil 6/15/2008 12:30:17 AM

Hello to all,

Frank's posting was great:

mov eax, dword ptr value
mov edx, dword ptr value + 4

and have the 64-bit value in edx:eax.

Thanks to all!
Jens 

0
Reply Jens 6/15/2008 7:27:14 AM

Phil Carmody wrote:
> Frank Kotler  <spamtrap@crayne.org> writes:
>> Jens Kallup wrote:
>>> Hello Newsgroup,
>>>
>>> how can I store a 64 bit value in a EAX register for
>>> 686 or below x86 32bit amd pc architectures?
>> Shoehorn! :)
>>
>>> .8087
>>> .386
>>> .model flat
>>> .code
>>>
>>> ; value = 4614253070214989087 // <-- this is it
>>>
>>> Entry:
>>> mov eax, <value>
>>> fld tbyte ptr [ebx]
>>> ret
>>>
>>> end Entry
>>> ; EOF
>> What you *can* do is store a pointer to a 64 bit number (a 32-bit
>> pointer, of course!) in eax. Did you mean to use both eax and ebx
>> above?
>>
>> mov eax, offset value
>> fld qword ptr [eax]
> 
> fld or fild - depending on value.

Good point. "fild" is probably correct... if we're even close to the 
"desired" answer.

Best,
Frank

0
Reply Frank 6/15/2008 12:59:39 PM

Jens Kallup wrote:
> Hello Newsgroup,
> 
> how can I store a 64 bit value in a EAX register for
> 686 or below x86 32bit amd pc architectures?
> 
> .8087
> .386
> .model flat
> .code
> 
> ; value = 4614253070214989087 // <-- this is it
> 
> Entry:
> mov eax, <value>
> fld tbyte ptr [ebx]
> ret
> 
> end Entry
> ; EOF
> 
> thanks for helping
> Jens 
> 

To store:

mov eax,valuelow32
xor eax,valuehigh32

Now eax contains both the low and high 32 bit halves.

I see you have doubts. Consider:

xor eax,valuelow32

Now eax contains the high 32 bit value.

xor eax,valuehigh32

Now eax contains the low 32 bit value.

Wiley Coyote,
genius programmer

0
Reply Scott 6/16/2008 6:33:33 PM

On Jun 17, 4:33 am, Scott Moore  <spamt...@crayne.org> wrote:
> Jens Kallup wrote:
> > Hello Newsgroup,
>
> > how can I store a 64 bit value in a EAX register for
> > 686 or below x86 32bit amd pc architectures?
<SNIP>
> > thanks for helping
> > Jens
....


> To store:
>
> mov eax,valuelow32
> xor eax,valuehigh32
>
> Now eax contains both the low and high 32 bit halves.
>
> I see you have doubts. Consider:
>
> xor eax,valuelow32
>
> Now eax contains the high 32 bit value.
>
> xor eax,valuehigh32
>
> Now eax contains the low 32 bit value.

Problem is although this operation is reversible, you will need 32
bits to hold either valuelow32 or valuehigh32 somewhere else to so as
you can retrieve the whole 64 bit value which ultimately leads to the
same no of bits of information (64) required.

I am not aware of a nice quick algorithm that will compress and store
a 64 bit immediate into a 32 bit reg (that will work in a generalised
way, all the time) for this purpose.

Using 2 registers is a lot less hassle even if such an algorithm is
possible, imho.

Unless there is some point here that I'm completely missing.
( Do enlighten me if there is indeed a use for this. )

> Wiley Coyote,
> genius programmer

Ah... maybe not ;)

Robert Spykerman

0
Reply Robert 6/17/2008 12:01:55 AM

Robert Spykerman enswered Scott Moore,

.... how to move 64 bits into eax ...

a joke is usually considered as not good if it needs explanation.
But I think Scott posted a 'good one' :)

__
wolfgang




0
Reply Wolfgang 6/17/2008 9:25:55 AM

11 Replies
224 Views

(page loaded in 0.128 seconds)

Similiar Articles:


















7/27/2012 10:11:02 AM


Reply: