public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* 16-bit code in GAS
@ 2003-08-15 13:44 Mikulas Patocka
  2003-08-15 15:25 ` Alan Modra
  0 siblings, 1 reply; 4+ messages in thread
From: Mikulas Patocka @ 2003-08-15 13:44 UTC (permalink / raw)
  To: binutils, bug-binutils

Hi

When I upgraded gas to 2.14, i found that it can't generate 32-bit
addresses in 16-bit mode (.code16) directive.

$ as
.code16
movl $0x12345678, 0xabcdef01
{standard input}: Assembler messages:
{standard input}:2: Warning: -1412567295 shortened to 61185
$ objdump --disassemble

a.out:     file format elf32-i386

Disassembly of section .text:

00000000 <.text>:
   0:   66 c7 06 01 ef          movw   $0xef01,(%esi)
   5:   78 56                   js     0x5d
   7:   34 12                   xor    $0x12,%al
A
The resulting instruction should have prefixes 66 and 67 and should have
32-bit address.

Info page says, the the function of instructions in 16-bit mode is
exacltly the same as in 32-bit mode, but it's not true.

Older versions of gas generated both address and instruction prefixes and
generated 32-bit address.

How can I write 32-bit code that runs in a segment with default operand
size 16 (without 'D' bit set)?

Mikulas

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: 16-bit code in GAS
  2003-08-15 13:44 16-bit code in GAS Mikulas Patocka
@ 2003-08-15 15:25 ` Alan Modra
  2003-08-15 16:05   ` Mikulas Patocka
  0 siblings, 1 reply; 4+ messages in thread
From: Alan Modra @ 2003-08-15 15:25 UTC (permalink / raw)
  To: Mikulas Patocka; +Cc: binutils, bug-binutils

On Fri, Aug 15, 2003 at 03:44:13PM +0200, Mikulas Patocka wrote:
> The resulting instruction should have prefixes 66 and 67 and should have
> 32-bit address.

It certainly looks buggy.  I would have expected that gas generate just
the data prefix and trim the address to 16 bit.  Instead we get a 32 bit
address inserted into the instruction.

> How can I write 32-bit code that runs in a segment with default operand
> size 16 (without 'D' bit set)?

 .code16
 addr32 movl $0x12345678, 0xabcdef01


-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: 16-bit code in GAS
  2003-08-15 15:25 ` Alan Modra
@ 2003-08-15 16:05   ` Mikulas Patocka
  2003-08-15 18:08     ` Ian Lance Taylor
  0 siblings, 1 reply; 4+ messages in thread
From: Mikulas Patocka @ 2003-08-15 16:05 UTC (permalink / raw)
  To: Alan Modra; +Cc: binutils, bug-binutils

> On Fri, Aug 15, 2003 at 03:44:13PM +0200, Mikulas Patocka wrote:
> > The resulting instruction should have prefixes 66 and 67 and should have
> > 32-bit address.
>
> It certainly looks buggy.  I would have expected that gas generate just
> the data prefix and trim the address to 16 bit.  Instead we get a 32 bit

It does exactly that, note that objdump --disassemble doesn't know about
.code16, so it displays nonsense --- you have to decode instruction
manually and it seems correct.

However I think it shouldn't do even that. Or maybe add another mode?:
1: .code16 (real mode or 286 protected mode)
2: .code32 without 'd' bit
3: .code32 with 'd' bit

On older versions .code16 used to behave like (2) but now it behaves like (1)

> address inserted into the instruction.
>
> > How can I write 32-bit code that runs in a segment with default operand
> > size 16 (without 'D' bit set)?
>
>  .code16
>  addr32 movl $0x12345678, 0xabcdef01

Thanks, it works.

Mikulas

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: 16-bit code in GAS
  2003-08-15 16:05   ` Mikulas Patocka
@ 2003-08-15 18:08     ` Ian Lance Taylor
  0 siblings, 0 replies; 4+ messages in thread
From: Ian Lance Taylor @ 2003-08-15 18:08 UTC (permalink / raw)
  To: Mikulas Patocka; +Cc: Alan Modra, binutils, bug-binutils

Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz> writes:

> It does exactly that, note that objdump --disassemble doesn't know about
> .code16, so it displays nonsense --- you have to decode instruction
> manually and it seems correct.

FYI, you can use objdump --disassemble -mi8086.

Ian

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2003-08-15 18:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-15 13:44 16-bit code in GAS Mikulas Patocka
2003-08-15 15:25 ` Alan Modra
2003-08-15 16:05   ` Mikulas Patocka
2003-08-15 18:08     ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).