课程列表

基本问题

开源资源

好好学习天天向上

联大大纲—通信电子 ;教师介绍; 单片机课程学习经验- 学习路线图; 1.概述 -应用 -定义 -特点 -构成; 2.嵌入式处理器 —DIY CPU处理器ARM处理器Cortex-A8S5PV210讨论; 3.汇编语言 -作业 4.Bootloader -作业 5.Linux内核移植 6.嵌入式Linux程序设计 7.图形用户接口QT 8.其他框架介绍; 9.嵌入式物联网应用系统设计

This page is copied from http://www.keil.com/support/man/docs/armasm/armasm_dom1359731144051.htm

An example ARM assembly language module

3.4 An example ARM assembly language module

An ARM assembly language module has several constituent parts.

These are:
  • ELF sections (defined by the AREA directive).
  • Application entry (defined by the ENTRY directive).
  • Application execution.
  • Application termination.
  • Program end (defined by the END directive).

Constituents of an assembly language module

The following example defines a single section called ARMex that contains code and is marked as being READONLY.
        AREA     ARMex, CODE, READONLY
                     ; Name this block of code ARMex
        ENTRY           ; Mark first instruction to execute
start
        MOV      r0, #10     ; Set up parameters
        MOV      r1, #3
        ADD      r0, r0, r1    ; r0 = r0 + r1
stop
        MOV      r0, #0x18      ; angel_SWIreason_ReportException
        LDR      r1, =0x20026   ; ADP_Stopped_ApplicationExit
        SVC      #0x123456     ; ARM semihosting (formerly SWI)
        END               ; Mark end of file

Application entry

The ENTRY directive declares an entry point to the program. It marks the first instruction to be executed. In applications using the C library, an entry point is also contained within the C library initialization code. Initialization code and exception handlers also contain entry points.

Application execution

The application code begins executing at the label start, where it loads the decimal values 10 and 3 into registers R0 and R1. These registers are added together and the result placed in R0.

Application termination

After executing the main code, the application terminates by returning control to the debugger. You do this using the ARM semihosting SVC (0x123456 by default), with the following parameters:
  • R0 equal to angel_SWIreason_ReportException (0x18).
  • R1 equal to ADP_Stopped_ApplicationExit (0x20026).

Program end

The END directive instructs the assembler to stop processing this source file. Every assembly language source module must finish with an END directive on a line by itself. Any lines following the END directive are ignored by the assembler.
Related reference
Related information