I am new in ARM and assembler. I tried to write a simple program to store value from register to memory.
string:
.ascii "%d\012\000"
.align 2
var1:
.word 0
.align 4
.text
.global main
main:
push {ip, lr}
ldr r1, adr_var1
ldrb r1, [r1]
mov r1, #370
uxtb r3, r1
ldr r1, adr_var1
strb r3, [r1]
ldr r0, adr_string
mov r1, r3
bl printf
mov r1, #0
mov r7, #1
pop {ip, pc}
adr_var1:
.word var1
adr_string:
.word string
The problem occurs when writing data to memory. When it tries to write the value 370 (hex: 0x172), only 0x72 is saved. STR seems to only transfer 8 data bits. I have tried different configurations with the STR instruction (e.g. STRB) and nothing works. My question is how can store this value to memory.
Thank you for any help and answer.