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

AREA Directive problem in ARM LPC2148

Hi all,

I am making some small programs in ARM assembly language.

I am using KEIL software for the programming and compialtion.

The problem I am facing is during a program in which data form one memory is copied to another memory.

The example I am following is given in the help file with KEIL uvision.

The Program is as follows :

=====================================================

AREA Word, CODE, READONLY ; name this block of code

num EQU 20 ; set number of words to be copied

ENTRY ; mark the first instruction called

EXPORT __main
__main
LDR r0, =src ; r0 = pointer to source block
LDR r1, =dst ; r1 = pointer to destination block
MOV r2, #num ; r2 = number of words to copy
wordcopy
LDR r3, [r0], #4 ; load a word from the source and
STR r3, [r1], #4 ; store it to the destination
SUBS r2, r2, #1 ; decrement the counter
BNE wordcopy ; ... copy more
stop
MOV r0, #0x18 ; angel_SWIreason_ReportException
LDR r1, =0x20026 ; ADP_Stopped_ApplicationExit
SVC #0x123456 ; ARM semihosting (formerly SWI)

AREA BlockData, DATA, READWRITE
src DCD 1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,2,3,4
dst DCD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
END

=====================================================

The Problem is data is not copied in the destination address nor I can read the data from the source.

As I am using KEIL so there is Startup.s file and I have commented the last part in the file which is :

=====================================================

; Enter the C code

IMPORT __main
LDR R0, =__main
BX R0

; IF :DEF:__MICROLIB
; ; EXPORT __heap_base
; EXPORT __heap_limit

; ELSE
; User Initial Stack & Heap
; AREA |.text|, CODE, READONLY

; IMPORT __use_two_region_memory
; EXPORT __user_initial_stackheap
;__user_initial_stackheap

; LDR R0, = Heap_Mem
; LDR R1, =(Stack_Mem + USR_Stack_Size)
; LDR R2, = (Heap_Mem + Heap_Size)
; LDR R3, = Stack_Mem
; BX LR
; ENDIF

=====================================================

and thats why I had used EXPORT __main in the starting of the progam.

Could any one please tell me what the problem is and where I am doing the mistakes.
As I am new to arm assembly ... so cant figure it out

regards
Arvind

Parents
  • Hi,

    thanx for your reply.

    As I am using KEIL uv 4 ... which takes Real View Compiler.

    The startup.s file is given by the IDE only.
    Before this I was having probs for the compilation and after searching so many forums including this I got to know that ... I have to comment some lines in the last block of this default file and in my assembly file I have to include

    EXPORT __main

    Then only my assembly program would get compile successfully. Fortunately it works ... but as of now ... the problem I am facing is in terms of memory.

    I have checked in the Debugger of keil that i cant even read the source data.

    If i write like this ... then it is working ...

    ====================================================

    AREA BlockData, DATA, READONLY
    src DCD 1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,2,3,4

    AREA BlockData, DATA
    dst DCD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 END

    =====================================================

    But my query is that with using READWRITE it should also work as per the tutorials given in the internet and all the books.

    regards
    Arvind

Reply
  • Hi,

    thanx for your reply.

    As I am using KEIL uv 4 ... which takes Real View Compiler.

    The startup.s file is given by the IDE only.
    Before this I was having probs for the compilation and after searching so many forums including this I got to know that ... I have to comment some lines in the last block of this default file and in my assembly file I have to include

    EXPORT __main

    Then only my assembly program would get compile successfully. Fortunately it works ... but as of now ... the problem I am facing is in terms of memory.

    I have checked in the Debugger of keil that i cant even read the source data.

    If i write like this ... then it is working ...

    ====================================================

    AREA BlockData, DATA, READONLY
    src DCD 1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,2,3,4

    AREA BlockData, DATA
    dst DCD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 END

    =====================================================

    But my query is that with using READWRITE it should also work as per the tutorials given in the internet and all the books.

    regards
    Arvind

Children
  • > If i write like this ... then it is working ...

    AREA BlockData, DATA, READONLY
    src DCD 1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,2,3,4
    
    AREA BlockData, DATA
    dst DCD 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 END
    

    Yes, because now source data (src) doesn't need to be relocated to RAM. Due to the READONLY attribute the linker will place the values in flash memory. You will observe, though, that the memory block beginning at dst isn't all zeros before __main() executes.

    Regards
    Marcus
    http://www.doulos.com/arm/

  • Thanx for ur reply ...

    But my point is ... is this the correct way of doing ...

    If i have to read and write the same memory at same time ... then what?

    I am using only KEIL debugger and not the real ARM board ... so is this so that ... it will work on the borad correctly?

    What mistake I am making here ... ?

    regards
    Arvind