Re: [arm-gnu] load constructed constant in arm inline assembly - how?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [arm-gnu] load constructed constant in arm inline assembly - how?



I can't use an inline function. I'm writing an operating system, so I need to write Position Independent startup code, the interrupt vector table, etc.

Your information about using the C pre-processor in the assembler is very very useful. Thank you very much.


From: Nick Clifton <nickc@xxxxxxxxxx>
To: Kurt Kennett <kurt_kennett@xxxxxxxxxxx>
CC: manningc2@xxxxxxxxxxxxx, arm-gnu@xxxxxxxxxxxxxxxx
Subject: Re: [arm-gnu] load constructed constant in arm inline assembly - how?
Date: Fri, 02 Sep 2005 09:02:29 +0100

Hi Kurt,

I don't want to duplicate my important definitions accross assembler format and C format of defines.

You can have the C pre-processor run on your assembler source file before it is handed to assembler itself. Thus you can use C header files in your assembler source programs. eg:

  #include "foo.h"
     .text
     ldr r0,=FOO

If you give your source file a .S extension (note the capital letter) then gcc will know to pass the source file through cpp first before giving it to gas. If you are running on a case-insensitive file system then you can use the "-x assembler-with-cpp" gcc command line switch instead.

Also, I can use the offsetof() macro to get structure member offsets, rather than making offsets for each member of a struct in assembler:

This is more difficult. Do you really need assembler instructions to access these structure fields ? Can't you make use of C instead ? Maybe an inline function ?

Cheers
  Nick





_________________________________________________________________
Scan and help eliminate destructive viruses from your inbound and outbound e-mail and attachments. http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines Start enjoying all the benefits of MSN® Premium right now and get the first two months FREE*.