This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Cannot use data allocation directives (assembly)

I am writing a program  to check if a given string is a palindrome and it is not running as expected. The code is from a textbook so it's not mine, but I can't understand why it's not running as it should. I actually had the same problem with a different program (which you can see on my stack overflow post here if you want) but I ignored it and moved on. I had the same issue again and I think the  'DCB' and 'DCD' instructions are not doing what they should. The reason I think that is the problem because when I look at the program in the debugger, the memory address that should be holding the string is clear. I don't know how to see what memory address holds a given variable but the address is loaded into r6 so I checked in memory area and its empty? What am I doing wrong?

Here's an image of my debugger window

My target device is an AMRCM7 by the way, and I'm on keil uvision v5.38a and the compiler is ARM compiler v6.19 

Here is my full code:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
AREA myData,DATA
ALIGN
string DCB "rats live on no evil star", 0 ; NULL terminator explicitly added
AREA palindrome,CODE
EXPORT __main
ALIGN
ENTRY
__main PROC
LDR r6, = string ; load address of string in r6
;Find string length
MOV r1,#0 ; len
MOV r5,r6 ; r5=string
strLen LDRB r2,[r5],#1 ;post-index
CMP r2,#0 ;Check for NULL character
ADDNE r1,r1,#1
BNE strLen
;Check palindrome
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

0