3

Hi I'm using the Keil uVision compiler for ARM assembly. I'm just starting out learning 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 build the target it says

test.s(1): error: A1163E: Unknown opcode PROGRAM, , expecting opcode or Macro

I'm not sure why that is. The code above s the code I was given to run as a sample to make sure its working. Shouldn't I be able to put anything in for AREA? Any help is appreciated.

HarvP
  • 190
  • 3
  • 13

2 Answers2

7

That error message is informative, if a little hard to decipher: anything that starts in the first column is considered to be a label, so the assembler sees a label named "AREA", then tries to interpret "PROGRAM," as a mnemonic, macro, or directive, which obviously fails since it isn't.

In short, directives need to be indented, just like instructions; this assembles just fine:

    AREA PROGRAM, CODE, READONLY
    EXPORT SYSTEMINIT
    EXPORT __MAIN
SYSTEMINIT
__MAIN
    MOV R1, #0X25
    MOV R2, #0X23
    END
Notlikethat
  • 20,095
  • 3
  • 40
  • 77
0

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

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

where:

sectionname s the name to give to the section. You can choose any name for your sections.

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

Further reading about directives you can find here.

Ruslan Gerasimov
  • 1,752
  • 1
  • 13
  • 20