MPLAB X IDE v2.35汇编代码,无法汇编(PIC16F84A)

时间:2015-04-20 11:21:01

标签: assembly makefile mplab

这是我第一次尝试在程序集中编程。愿你能帮我解决这个错误。这是我使用的代码,您可以在下面找到错误消息。 如标题所述,IDE是MPLAB X IDE v2.35,我使用的是Michrochip PIC16F84A。

    ;******************************************************************************
;  File Name    : main.asm
;  Version      : 1.0
;  Description  : Test Program
;  Author       : Me
;  Last Updated : 20 April 2015
; *******************************************************************


    list p=16f84
    radix hex

;   Register
STATUS      equ     0x03
OPTION_REG  equ     0x81
PORTA       equ     0x05
PORTB       equ     0x06
TRISA       equ     0x85
TRISB       equ     0x86

;   STATUS Register Bits
RP0         equ     0x05    ; 0 = Bank 0 0x00 - 0x7F, 1 = Bank 1 0x80 - 0xFF


;_________________________________________________________________
;Mainprogram

    BSF STATUS,RP0         ;   Change to RAM Bank 1
    BSF TRISB,2            ;   Set RB2 output to 1
    BCF STATUS,RP0         ;   Change to RAM Bank 0
    BCF PORTB,2            ;   Define RB2 as output

    end

这是我从MPLAB获得的错误消息:

make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory 'C:/Users/xxx/MPLABXProjects/Test.X'
make  -f nbproject/Makefile-default.mk dist/default/production/Test.X.production.hex
make[2]: Entering directory 'C:/Users/xxx/MPLABXProjects/Test.X'
make[2]: *** [build/default/production/main.o] Error 1
make[1]: *** [.build-conf] Error 2
make: *** [.build-impl] Error 2
"C:\Program Files (x86)\Microchip\MPLABX\mpasmx\mpasmx.exe" -q -p16f84a -l"build/default/production/main.lst" -e"build/default/production/main.err" -o"build/default/production/main.o" "main.asm" 
Warning[203] C:\USERS\xxx\MPLABXPROJECTS\TEST.X\MAIN.ASM 29 : Found opcode in column 1. (BSF)
Error[152]   C:\USERS\xxx\MPLABXPROJECTS\TEST.X\MAIN.ASM 29 : Executable code and data must be defined in an appropriate section
Warning[203] C:\USERS\xxx\MPLABXPROJECTS\TEST.X\MAIN.ASM 30 : Found opcode in column 1. (BSF)
Message[302] C:\USERS\xxx\MPLABXPROJECTS\TEST.X\MAIN.ASM 30 : Register in operand not in bank 0.  Ensure that bank bits are correct.
Error[152]   C:\USERS\xxx\MPLABXPROJECTS\TEST.X\MAIN.ASM 30 : Executable code and data must be defined in an appropriate section
Warning[203] C:\USERS\xxx\MPLABXPROJECTS\TEST.X\MAIN.ASM 31 : Found opcode in column 1. (BCF)
Error[152]   C:\USERS\xxx\MPLABXPROJECTS\TEST.X\MAIN.ASM 31 : Executable code and data must be defined in an appropriate section
Warning[203] C:\USERS\xxx\MPLABXPROJECTS\TEST.X\MAIN.ASM 32 : Found opcode in column 1. (BCF)
Error[152]   C:\USERS\xxx\MPLABXPROJECTS\TEST.X\MAIN.ASM 32 : Executable code and data must be defined in an appropriate section
nbproject/Makefile-default.mk:95: recipe for target 'build/default/production/main.o' failed
make[2]: Leaving directory 'C:/Users/xxx/MPLABXProjects/Test.X'
nbproject/Makefile-default.mk:78: recipe for target '.build-conf' failed
make[1]: Leaving directory 'C:/Users/xxx/MPLABXProjects/Test.X'
nbproject/Makefile-impl.mk:39: recipe for target '.build-impl' failed

BUILD FAILED (exit value 2, total time: 806ms)

1 个答案:

答案 0 :(得分:1)

您缺少该处理器的.inc文件,您必须包含以下内容:

list p=16f84
#include "p16f84A.inc"

如果你这样做,你不需要像你那样声明SFR寄存器,你必须删除以下代码以避免冲突:

;   Register
STATUS      equ     0x03
OPTION_REG  equ     0x81
PORTA       equ     0x05
PORTB       equ     0x06
TRISA       equ     0x85
TRISB       equ     0x86

指定程序的入口点和中断向量也是一个好主意,对于你的处理器它们应该是这样的:

ORG 0x00
goto Main_Program
ORG 0x04 
goto Main_Program    ; If you are not using interrupt routines

Main_Program
    <your code here>
    end

除此之外,您还缺少配置指令。 这是一个通用程序模板:

        PROCESSOR  16F84A
        #include   "p16f84A.inc"
        __CONFIG   _MCLRE_OFF & _CP_OFF & _WDT_OFF

;-- Definitions ------------------------------------------------
#define OUT1 PORTB,0        ; 
;-- variables --------------------------------------------------    
temp0   equ 20h             ; 
;---------------------------------------------------------------                                          
        org     0x00
        goto    init
        org     0x04
        goto    init

init

    <pheriperal and port configuration> 

main

    <your program here>

    goto main

    end

在MPLABX中,您可以从以下菜单条中查看可用于处理器的配置位:Window&gt; PIC存储器视图&gt;配置位 将它们添加到此表单

下的配置中
相关问题