Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Howto Push

10 views
Skip to first unread message

Bernd Gerber

unread,
Dec 21, 2009, 4:11:06 PM12/21/09
to

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

David

unread,
Dec 21, 2009, 9:19:36 PM12/21/09
to

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

Frank Kotler

unread,
Dec 21, 2009, 10:12:42 PM12/21/09
to

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

Alexei A. Frounze

unread,
Dec 22, 2009, 6:16:55 AM12/22/09
to

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 pm, David <d...@nowhere.net> wrote:
> 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
>

Tim Roberts

unread,
Dec 23, 2009, 5:02:50 AM12/23/09
to

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, ti...@probo.com
Providenza & Boekelheide, Inc.

0 new messages