I am trying this assembly program for the armv5 connex board in Qemu. I am adding two numbers and storing them in the location label result. I am unable to view the result value 40 in the memory location, but the register value r4 = 0x28.
.data
val1: .4byte 10
val2: .4byte 30
result: .4byte 0
.text
.align
start:
ldr r0, =val1
ldr r1, =val2
ldr r2, [r0]
ldr r3, [r1]
add r4, r2, r3
ldr r0, =result
str r4, [r0]
stop: b stop
My Linker script is
SECTIONS {
. = 0x00000000;
.text : {
*(.text);
}
.data : {
*(.data);
}
}
Output
user@stretch:~/Desktop/Gnu_Toolchain/Data_In_Ram$ arm-none-eabi-nm -n data_in_ram.elf
00000000 t start
0000001c t stop
0000002c d val1
00000030 d val2
00000034 d result
info registers
R00=00000034 R01=00000030 R02=0000000a R03=0000001e
R04=00000028 R05=00000000 R06=00000000 R07=00000000
R08=00000000 R09=00000000 R10=00000000 R11=00000000
R12=00000000 R13=00000000 R14=00000000 R15=0000001c
PSR=400001d3 -Z-- A svc32
FPSCR: 00000000
(qemu) xp /3dw 0000002C
xp: extraneous characters at the end of line
Try "help xp" for more information
(qemu) xp /3dw 0x0000002C
000000000000002c: 10 30 0
(qemu) xp /4dw 0x0000002C
000000000000002c: 10 30 0 0
(qemu)
On the Connex board, physical address zero has ROM, not RAM. So you can ask QEMU to load code there, and you can execute it and your program can read data from it, but any attempt by the code to write there will simply be ignored. This explains the results you see.
Your code either needs to be able to relocate itself into the RAM, or else you should just set up your linker map so that it goes there in the first place. RAM on the Connex board starts at 0xA000_0000.
PS: why are you using a model of an ancient PXA255-based system?
User contributions licensed under CC BY-SA 3.0