I'm beginner to Mplab and microController programing.i'm following a pic book .basically my program is a led turn on and off program .I'm using mplabx-v2.10
.this is not my complete code.however the error comes from line
BSF STATUS, 5
my code
STATUS EQU 03H
TRISA EQU 85H
PORTA EQU 05H
BSF STATUS, 5
END
the error is
Error[152] C:\USERS\MADHAWAX\MPLABXPROJECTS\P-STAR1.X\NEWASMTEMPLATE1.ASM 6 : Executable code and data must be defined in an appropriate section
Best Answer
You need to separate the data and code with appropriate keywords. So, for example, you start off with some declaration of the PIC type and any included files:
Next, you can declare variables in a data section (this is just a generic example):
Normally, you then start the code section, using the keyword
CODE
, and add a goto from the reset vector (where the processor starts executing):Then, you declare any further CODE sections, for example:
I think your problem is that you have started writing code without declaring a
CODE
section.EDIT Just fixing your code by adding the
CODE
keyword and the initial jump from the reset vector compiles fine:You also need to make sure you respect the necessary indents/initial spaces in code lines so that they are not mistaken for labels. Your first block of code (under MAIN) was not indented, so also caused errors.