Keil™, An ARM® Company

Discussion Forum

Need help with simple assembly language program

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Author
Arnold Berger
Posted
9-May-2008 19:03
Toolset
ARM
New! Need help with simple assembly language program

Hello, I teach Computer Architecture at the University of Washington Bothell campus. I'm teaching the ARM 7 architecture for the first time and this is the first time I'm using the uVision toolset. I'm having trouble getting simple programs to assemble and link so I can single step them in the ISS so I can do simple demos for my students and have them do simple programming assignments. I seem to be stymied by the linker. Can someone send me a simple skeleton that I can use to create short programs that I can use?

What I've tried so far. I got a sample program from the ARM ADS 1.2 CD-ROM that I have (shown below). I added the label, __main and place the pseudo-op instruction,
EXPORT __main. That seemed to fix one error and introduced another one. I seem to always be one error away from getting it to build. I included the startup.s file in the project. Here is the error message that I receive:

ASM_test.axf: Error: L6218E: Undefined symbol __use_two_region_memory (referred from startup.o)

Thanks in advance for any help that you could provide.

Arnie

Here's my program code:


AREA    Jump, CODE, READONLY    ; name this block of code
        CODE32                          ; Following code is ARM code

num     EQU     2               ; Number of entries in jump table

        ENTRY                   ; mark the first instruction to call
;removed start
__main
        MOV     r0, #0          ; set up the three parameters
        MOV     r1, #3
        MOV     r2, #2
        BL      arithfunc       ; call the function

stop
        MOV     r0, #0x18       ; angel_SWIreason_ReportException
        LDR     r1, =0x20026    ; ADP_Stopped_ApplicationExit
        SWI     0x123456        ; ARM semihosting SWI

arithfunc                       ; label the function
        CMP     r0, #num        ; Treat function code as unsigned integer
        MOVHS   pc, lr          ; If code is >= num then simply return
        ADR     r3, JumpTable   ; Load address of jump table
        LDR     pc, [r3,r0,LSL#2]       ; Jump to the appropriate routine

JumpTable
        DCD     DoAdd
        DCD     DoSub

DoAdd
        ADD     r0, r1, r2      ; Operation 0
        MOV     pc, lr          ; Return

DoSub
        SUB     r0, r1, r2      ; Operation 1
        MOV     pc,lr           ; Return
                EXPORT  __main

        END                     ; mark the end of this file
Author
Tamir Michael
Posted
9-May-2008 23:25
Toolset
ARM
New! RE: Need help with simple assembly language program

in the ARM startup procedure, the function __main initializes the runtime environment and executes the user application by calling __rt_entry. maybe that is your problem?

Author
Arnold Berger
Posted
10-May-2008 10:08
Toolset
ARM
New! RE: Need help with simple assembly language program

I got it working. The instructions weren't much help but I kept playing around with it until I got it to assemble and link. Thanks for your help.

Arnie

Next Thread | Thread List | Previous Thread Start a Thread | Settings