AREA field in an ARM assembly

Hi I am using Keil uVision compiler to build ARM. I am just starting to learn this and I have the following code in my program.

AREA PROGRAM, CODE, READONLY
EXPORT SYSTEMINIT
EXPORT __MAIN
SYSTEMINIT
__MAIN
    MOV R1, #0X25
    MOV R2, #0X23
    END

      

When I create a goal, it says

test.s (1): error: A1163E: Unknown opcode PROGRAM pending opcode or macro

I'm not sure why this is the case. The code above s the code I was given to work as a sample to make sure it works. Can't I put something in AREA? Any help is appreciated.

+3


source to share


2 answers


This error message is informative if a little hard to decipher: anything that starts in the first column counts as a label , so the assembler sees a label named "AREA", then tries to interpret "PROGRAM" as a mnemonic, macro, or directive that obviously tolerates fail as it is not.

In short, directives should be indented just like instructions; it's very simple:



    AREA PROGRAM, CODE, READONLY
    EXPORT SYSTEMINIT
    EXPORT __MAIN
SYSTEMINIT
__MAIN
    MOV R1, #0X25
    MOV R2, #0X23
    END

      

+7


source


The AREA directive instructs the assembler to assemble a new section of code or data. Sections are independent, called indivisible chunks of code or data, that are manipulated by the linker. Syntax

AREA sectionname{,attr}{,attr}...

      

Where:



sectionname s is the name to be passed to the section. You can choose any name for your sections.

So, check that you have the same name in both places: right after the AREA directive and somewhere in your code.

You can find more details about directives here .

0


source







All Articles