Alfred Huang's Weblog

Disclaimer: Whatever I suggested in my blog is what I would do, it does not necessarily mean the only way to do it.


« Previous month (Nov 2007) | Main | Next month (Jan 2008) »
Monday Dec 10, 2007

Compatibility between Sun and GNU Assembler

The latest patch for Sun Studio 12 Assembler has some modifications that may be of interest to some developers with existing assembly source previously written for the GNU Assembler; Sun Studio 12 Assembler is now more syntatically compatible with GNU Assembler!

    There are 2 new assembler options:

  1. -C: In general you do not need -C to be GNU Assembler compatible, -C is only needed in several situations to make the semantic compatible. Please refer to the changes below.
  2. -a32: To allow 32-bit memory address in -m64 64-bit mode.

    Major area of changes:

  1. For mnemonics without suffix, the presence of register operand determines the suffix implicitly. If size of operation can not be determined due to absence of register operand, an error is issued if the option -C was used, otherwise the suffix defaults to 'l'.
      For example:      mov $10, %ax
                        can now be used for
                        movw $10, %ax
    
      Note if we have:  mov $10, mem
                        Sun Assembler will default to become
                        movl $10, mem
                        But give an error if -C is used to be compatible
                        with GNU Assembler
    
  2. Allow all 16-bit instructions to accept 32-bit register operands, but to issue warning if -C option is used.
  3. Allow 32-bit address under 64-bit mode using the new option -a32.
       For example:     "fbe -m64 -a32 file.s" can assemble
                        lea 123(%eax,%r10d),%eax
    
  4. We can now have more than 10 local labels, a local label can now be as large as a 32-bit integer.
  5. You can now place "lock/rep/repnz/repz/repe/repne" prefix on the same line as the following instruction.
  6. Some new GNU Assembler compatible instruction synonyms: cbw==cwtd, cwd==cwtd, cwde==cwtl, cdq==cltd, cdqe==cltq, cqo==cqto, movzb==movzbl, sysret==sysretl
  7. Some new GNU Assembler compatible assembler directives: .p2align, .extern, .global, .equiv

Today's Page Hits: 15