How to specify a different name in the register in the GNU ARM assembler?

I have tiva with TM4C123GH6PM and I just installed the GNU ARM toolchain. I want to program only in the assembly, because I would like to create a FORTH system for it, but when I use

.equ  W, r2             // working register

this gives the symbol r2

add W, IP, #4
main.S(54): error: undefined symbol r2 used as an immediate value

then I changed to:

#define W r2

now gives

add W, IP, #4
main.S(55): error: undefined symbol W used as an immediate value

Questions:

  • Can I change the name?
  • If not, can I use the predecessor C for this?
+4
source share
2 answers

To create an alias for a register, use .req:

W .req r2
...
add W, IP, #4
+5
source

You cannot rename registers.

, GCC, as. arm-none-eabi-cpp, :

  • .S ( ) GCC (, arm-none-eabi-gcc -c foo.S -o foo.o). .S .
  • , , -x assembler-with-cpp GCC (, arm-none-eabi-gcc -c -x assembler-with-cpp foo.bar -o foo.o. -x assembler .

Keil, .sx ( ). , GCC -x.

+2

Source: https://habr.com/ru/post/1654955/


All Articles