Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to give a different name to a register in GNU ARM assembler?

I have tiva c TM4C123GH6PM and I have just installed a GNU ARM tool chain. I want to program only in assembly, because I would like to a build FORTH system for it, but when I use

.equ  W, r2             // working register

this gives a 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:

  • Is it possible to change the name?
  • If not, can I use a C predecessor for that?
like image 927
I.Omar Avatar asked Sep 18 '16 05:09

I.Omar


1 Answers

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

W .req r2
...
add W, IP, #4
like image 181
Notlikethat Avatar answered Sep 28 '22 19:09

Notlikethat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!