I'm not sure if this is the forum I should be asking this question, but it's the closer I found.
I want to create a variable in assembly and use it in two functions that are in the same assembly file. Reading the ARM Assembly Language Tools User's Guide I could make it work just like the example code below:
; create an uninitialized section named variable with 4 bytes ; is this how a variable is created is TI Assembly? .bss variable, 4 ; I written this but I don't know how it works ; without this line code doesn't work variable_addr .field variable, 32 .text .global foo .global bar ; the functions are just to show how I am trying to use the variable foo: ldr r1, variable_addr ; load the address of the variable in R1 ldr r2, #0x01 str r2, [r1] ; save 0x01 in the variable bx lr bar: ldr r1, variable_addr ; .... ; do something with the variable ; .... bx lr
Am I creating and using variables the right way? I read the docs, I read a lot of forum questions, but I still don't know how to do that.
I know the variable is created in line 3, I just don't know how to use it without that .field thing.