0

I am working of a code but I keep having an error when I try to run. I pasted the error below and I also added a screenshot. Thanks for the help..

Title "PIC18F452"
List p=18F452, f =inhx32
#include <p18F452.inc>  ;This is a header file 

REG00   EQU 0x00            ;Register 00H is labeled as REG00
REG01   EQU 0x01            ;Register 01H is labeled as REG01
REG02   EQU 0x02            ;Register 02H is labeled as REG02
REG03   EQU 0x03            ;Register 03H is labeled as REG03
REG04   EQU 0x04            ;Register 04H is labeled as REG04
REG05   EQU 0x05            ;Register 05H is labeled as REG05
REG10   EQU 0x10            ;Register 10H is labeled as REG10

        MOVLW   0x11        ;Load the first Hex number 11H in WREG
        MOVWF   REG00       ;Store 11H in File Register 00H in data memory
        MOVWF   REG01       ;Store 11H in File Register 01H in data memory
        MOVWF   REG02       ;Store 11H in File Register 02H in data memory
        MOVWF   REG03       ;Store 11H in File Register 03H in data memory
        MOVWF   REG04       ;Store 11H in File Register 04H in data memory
        MOVWF   REG05       ;Store 11H in File Register 00H in data memory
        MOVWF   REG00       ;Store 11H in File Register 00H in data memory


        ADDWF   REG01, W     
        ADDWF   REG02, W     
        ADDWF   REG03, W    
        ADDWF   REG04, W    
        ADDWF   REG05, W    

        MOVWF   REG10       ;Save the sum in File Register 10H
        END

enter image description here

"C:\Program Files (x86)\Microchip\MPLABX\v4.05\mpasmx\mpasmx.exe" -d__DEBUG -d__MPLAB_DEBUGGER_SIMULATOR=1 -q -p18f452 -l"build/default/debug/addingnumber.lst" -e"build/default/debug/addingnumber.err" -o"build/default/debug/addingnumber.o" "addingnumber.asm"
 make[1]: *** [.build-conf] 
 Error 2
 Error[152]
 C:\USERS\INTEL\MPLABXPROJECTS\PROGRAM1.X\ADDINGNUMBER.ASM 13 : Executable code and data must be defined in an appropriate section
 Error[152]
 C:\USERS\INTEL\MPLABXPROJECTS\PROGRAM1.X\ADDINGNUMBER.ASM 14 : Executable code and data must be defined in an appropriate section 
Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • "C:\Program Files (x86)\Microchip\MPLABX\v4.05\mpasmx\mpasmx.exe" -d__DEBUG -d__MPLAB_DEBUGGER_SIMULATOR=1 -q -p18f452 -l"build/default/debug/addingnumber.lst" -e"build/default/debug/addingnumber.err" -o"build/default/debug/addingnumber.o" "addingnumber.asm" make[1]: *** [.build-conf] Error 2 Error[152] C:\USERS\INTEL\MPLABXPROJECTS\PROGRAM1.X\ADDINGNUMBER.ASM 13 : Executable code and data must be defined in an appropriate section Error[152] C:\USERS\INTEL\MPLABXPROJECTS\PROGRAM1.X\ADDINGNUMBER.ASM 14 : Executable code and data must be defined in an appropriate section – Abdoul Oued Nov 18 '17 at 07:08
  • 1
    Looks like you need some kind of `section` directive. Read the manual or look for an example of a working program. – Peter Cordes Nov 18 '17 at 07:14
  • Peter is right, code must be in a `CODE` section. See also: https://electronics.stackexchange.com/questions/162225/mplab-error-executable-code-and-data-must-be-defined-in-an-appropriate-section – Ruud Helderman Nov 18 '17 at 09:47

0 Answers0