how to embed an arbitrary opcode

Nick Clifton nickc@redhat.com
Fri Jun 19 14:20:00 GMT 2009


Hi Richard,

> Yay!  Something I've wanted for a long time...

:-)

> One question.  What happens if .iword is used in Thumb mode, or .ishort
> in ARM mode?

Well the new pseudos explicitly set the mapping state based on their 
size, so for example if .iword were used in Thumb mode it would cause a 
$a symbol to be emitted at point.  Ie:

   % cat fred.s
         .text
         .global foo
   foo:
         nop
         .iword  0xe320f003
         nop
         .ishort 0x1234
         nop

         .thumb
         .global bar
   bar:
         nop
         .ishort 0x1234
         nop
         .iword 0xe320f003
         nop

   % as fred.s -o fred.o
   % objdump -d fred.o
   00000000 <foo>:
    0:   e1a00000        nop                     (mov r0,r0)
    4:   e320f003        wfi
    8:   e1a00000        nop                     (mov r0,r0)
    c:   1234            asrs    r4, r6, #8
    e:   e1a00000        nop                     (mov r0,r0)

   00000012 <bar>:
   12:   46c0            nop                     (mov r8, r8)
   14:   1234            asrs    r4, r6, #8
   16:   46c0            nop                     (mov r8, r8)
   18:   e320f003        wfi
   1c:   46c0            nop                     (mov r8, r8)


> I think it would be better to just have .insn (or .inst),
> which takes 32-bit numbers in ARM state and 16-bit numbers in thumb.
> The assembler has to know what state it's in anyway in order to generate
> the correct mapping symbol information.

I suspect that users are going to want to be able to use this mechanism 
to insert arbitrary ARM or THUMB opcodes at arbitrary places without 
regard to whether the assembler is currently in arm mode or thumb mode.

It would be quite easy to extend the patch however to add a third pseudo 
op (.inst is fine by me) which chooses it size based on the current 
mode.  So attached is an improved version of the patch which does just 
that.  Let me know what you think and if everyone likes it I will check 
it in.  (Along with a testcase based on the fred.s file above).

Cheers
   Nick

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: arm.iword.patch
URL: <https://sourceware.org/pipermail/binutils/attachments/20090619/16c2bc84/attachment.ksh>


More information about the Binutils mailing list