I am new to ARM Assembly programming using Keil 4, I have been trying to assemble two subroutines in assembly files. One of the subroutines calls the other.
Calling (Branching) a subroutine placed within the same file works, but, if one subroutine is placed in a separate file the following error message comes up
file2.s(8): error: A1163E: Unknown opcode SUBROUTE , expecting opcode or Macro
The code is appended below
FILE 1
;; Directives
PRESERVE8
THUMB
UNIFIED
AREA RESET, DATA, READONLY
EXPORT __Vectors
__Vectors
DCD 0x20001000 ; stack pointer value when stack is empty
DCD Reset_Handler ; reset vector
ALIGN
AREA MYCODE, CODE, READONLY
IMPORT SUBROUTE
ENTRY
EXPORT Reset_Handler
Reset_Handler
MOV R1, #0x0A ; Set loop counter
MOV R0,#00 ;intilaize resultant register
loop1 CBZ R1,FINISH ; if loop counter = 0 then exit the loop
BL SUBROUTE
B loop1 ; next loop
FINISH B FINISH ; keep looping
END ; end of program
FILE 2 :
AREA subroutine, CODE, READONLY
EXPORT SUBROUTE
SUBROUTE ADD R0,R1 ; Addition opertaion
SUB R1, #1 ; loop counter decrement
BX lr
END
Armasm labels have to start in the first column. Make sure there are no leading spaces/tabs before SUBROUTE
and FINISH
on the lines where they are defined. On the other hand, directives (like AREA
and IMPORT
) must not start in the first column and must have some leading whitespace.