Howto Push

  • Follow


Hi,

I am learning assembler programming on 64-bit Linux.
The instruction  "push edx" ends up with the error "instruction not 
supported in 64-bit mode", the instrucion "push rdx" works fine.
What do I have to do to push edx?

Thanks,
Bernd
0
Reply Bernd 12/21/2009 9:11:06 PM

Read and understand the Intel and/or AMD instruction manuals.  Some
combinations, including the one you want, appear to be illegal.

On 21 Dec 2009 21:11:06 GMT, Bernd Gerber
<BerndGerber@MUNGED.microcosmotalk.com> wrote:

>
>Hi,
>
>I am learning assembler programming on 64-bit Linux.
>The instruction  "push edx" ends up with the error "instruction not=20
>supported in 64-bit mode", the instrucion "push rdx" works fine.
>What do I have to do to push edx?
>
>Thanks,
>Bernd
0
Reply David 12/22/2009 2:19:36 AM


Bernd Gerber wrote:
> Hi,
> 
> I am learning assembler programming on 64-bit Linux.
> The instruction  "push edx" ends up with the error "instruction not 
> supported in 64-bit mode", the instrucion "push rdx" works fine.
> What do I have to do to push edx?

Hi Bernd,

Well... you can push rdx, that'll push edx too... I assume you know how 
the registers fit together(?). Or you can write 32-bit code, and just 
push edx.

If you're "just learning assembly", you might be better off to start 
with 32-bit. Only because the instructional materials and examples 
you'll find will mostly be 32-bit. 64-bit is still "pioneer land", to an 
extent. There's this "work in progress" for 64-bit:

http://www.vikaskumar.org/amd64/index.htm

And there's this:

http://milw0rm.org/papers/110

In order to get your ld (64-bit, I presume) to do 32-bit code, add 
"-melf_i386" to the command line. If you're using Nasm, "-f elf32" (or 
just "-f elf") instead of "-f elf64", of course. I think for (G)as, it's 
just "-386"(?).

If you're "just learning 64-bit assembly", you just learned your first 
lesson: push rdx. :)

Best,
Frank
0
Reply Frank 12/22/2009 3:12:42 AM

Oddly enough, one can PUSH DX in 64-bit mode. If the assembler for
some reason doesn't accept "PUSH DX" as-is in 64-bit mode, one can
encode it as "DB 66H, 52H".

Alex

On Dec 21, 6:19=A0pm, David <d...@nowhere.net> wrote:
> Read and understand the Intel and/or AMD instruction manuals. =A0Some
> combinations, including the one you want, appear to be illegal.
>
> On 21 Dec 2009 21:11:06 GMT, Bernd Gerber
>
> <BerndGer...@MUNGED.microcosmotalk.com> wrote:
>
> >Hi,
>
> >I am learning assembler programming on 64-bit Linux.
> >The instruction =A0"push edx" ends up with the error "instruction not
> >supported in 64-bit mode", the instrucion "push rdx" works fine.
> >What do I have to do to push edx?
>
> >Thanks,
> >Bernd
>
>

0
Reply Alexei 12/22/2009 11:16:55 AM

Bernd Gerber <BerndGerber@MUNGED.microcosmotalk.com> wrote:
>
>I am learning assembler programming on 64-bit Linux.
>The instruction  "push edx" ends up with the error "instruction not 
>supported in 64-bit mode", the instrucion "push rdx" works fine.
>What do I have to do to push edx?

In 64-bit code, the stack is always manipulated in 64-bit units.  The
calling convention requires this.  So, to push edx, you push rdx instead.
-- 
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
0
Reply Tim 12/23/2009 10:02:50 AM

4 Replies
107 Views

(page loaded in 0.245 seconds)

6/20/2013 5:24:43 AM


Reply: