[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Stack Overflow question about jmp

From: Thomas Preud'homme
Subject: Re: [Tinycc-devel] Stack Overflow question about jmp
Date: Sun, 22 Sep 2013 19:55:11 +0200
User-agent: KMail/4.10.5 (Linux/3.10-3-amd64; KDE/4.10.5; x86_64; ; )

Le dimanche 22 septembre 2013 18:16:06 grischka a écrit :
> Thomas Preud'homme wrote:
> > So I looked at it and the reason it works on x86_64 but not on i386 target
> > is that for i386 target it only works when I386_ASM_16 is defined (16-bit
> > support). It seems from (i386|x86_64)-asm.h that jmp can take a register
> > (such as %eax) instead of an address (*%eax). I guess in one case
> > (register) it does a jump relative to the beginning of the segment while
> > for the address case it's an absolute jump at the address stored in the
> > register.
> I have no idea what the '*' means with "jmp *%eax" but according
> to gcc it doesn't make a difference whether or not it is there.
> (both emit FFE0).

x86_64-asm.h defines 3 kind of jmp instruction, 2 of them being:

ALT(DEF_ASM_OP1(jmp, 0xff, 0, OPC_JMP | OPC_WL, OPT_REGW))

so basically the star select between the two. *%eax means indirection so first 
kind, %eax means register so second choice. If gcc treat both syntax as the 
same it means one of the two is incorrect.

Note that in my case, on x86_64, both syntaxs are refused by gcc, even with 
ecx as suggested in the stackoverflow link. I've tried on i386 and as outputs: 
"Warning: indirect jmp without `*'" so I guess the second alternative is wrong 
and should be removed. Can someone confirm this?

> Beyond that
>      error: unknown opcode 'jmp'
> is just a rather bad message.  Maybe it could say something like
>      error: bad operand '%eax' with opcode 'jmp'

A test could be added with a TOK_ASM_allfirst and TOK_ASM_alllast to 
distinguish between incorrect operand and incorrect opcode.

> --- grischka


Attachment: signature.asc
Description: This is a digitally signed message part.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]