3

I'm trying to store a value in memory. my code is here:

        TTL TEST
        global main

        AREA PROGRAM, CODE, READONLY
        ENTRY

main
        ADR     R0, DATA
        MOV     R1, #5
        STR     R1, [R0]

HALT        B       HALT

DATA    DCD     10

        END

I'm using KEIL uvision4, and my target is STM32F407VGT microprocessor. While debugging code, nothing changes in memory windows. What's wrong?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
01000110
  • 282
  • 1
  • 3
  • 16
  • 4
    It looks to me like you've placed your `DATA` variable in the `CODE` `AREA`, which is `READONLY`. – Michael Jan 18 '15 at 19:55
  • 1
    @Michael I don't know how to define separate areas in arm assembly. I've tried to add "AREA programdata, DATA, READWRITE" just before DATA but it didn't work. I have changed "READONLY" to "READWRITE" but it didn't work for me either. – 01000110 Jan 19 '15 at 21:11
  • Then it's probably a good idea to read [the documentation for `AREA`](http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0489c/Cacbjgcc.html). – Michael Jan 20 '15 at 06:26
  • 1
    @Michael I've read it many times! but it didn't help me to solve this problem! @_@ – 01000110 Jan 21 '15 at 09:47

1 Answers1

2

This is a piece of code I rewrote from some earlier code of mine. (I didn't test it again)

   PRESERVE8
   TTL TEST
   global main

   AREA asectionname, DATA, READWRITE
DATA DCD 10

   AREA PROGRAM, CODE, READONLY
   ENTRY

main
   ADR  R0, DATA
   MOV  R1, #5
   STR  R1, [R0]

HALT 
   B    HALT
   END

By adding AREA asectionname, DATA, READWRITE the thereon following lines are going to be placed in a RAM area and is able to be read and written to. DATA DCD 10 declares a variable called DATA which is the size of 1 word with the initial value of 10. (DCD allocates a full word, DCB alloctes a byte)

Please take a look at this page for further pointers on what to do and how things work.

Tarick Welling
  • 3,119
  • 3
  • 19
  • 44
  • 1
    [The args to `DCD` are a list of values, not a size](http://www.keil.com/support/man/docs/armasm/armasm_dom1361290005934.htm). `DCD 10` emits 1 word with value `10` (in the current AREA). – Peter Cordes May 16 '19 at 14:41