Search code examples
armkeil

How to write at least two `area`s in ARM assembly?


I'm trying to write an area which defines my data on the RAM, and an area for my code. I tried to do that, but I just can't make it work. I also tried using EXPORT and IMPORT but I couldn't solve various errors while using them.

    AREA HEAP, READWRITE, ALIGN=3
MYSTR   DCB "JaVid",0

    AREA RESET, CODE, READONLY
        ;IMPORT MYSTR

        ENTRY
        ADR R0, MYSTR   ;STRING POINTER

NEXT    LDRB R1, [R0]   ;CHARACTER HOLDER
        CMP R1, #'a'
        BLT OK
        CMP R1, #'z'
        BGT OK

        ;WE NEED TO SWITCH
        SUB R1, #'a'-'A'

OK      STRB R1, [R0], #1
        B NEXT

    END

Would you please give me an example of how it's done?


Solution

  • I suspect you may be having problems because you cannot use ADR to refer to a symbol in another AREA. See this section of the fine manual

    You probably want to use LDR r0, =MYSTR instead.

    Also, your loop does not seem to terminate.

    [Note: It would be helpful it you showed the exact error message you are getting and the command lines you are using with the code above.]