2015-04-20 72 views
0

這是我第一次嘗試編譯彙編。願你能幫助我解決這個錯誤。以下是我使用的代碼,您可以在下面找到錯誤消息。如標題所述,IDE是MPLAB X IDE v2.35,我使用的是Michrochip PIC16F84A。MPLAB X IDE v2.35彙編程序代碼,無法彙編(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) 
+0

這似乎不是你正在組裝的實際代碼。錯誤消息指的是您發佈的代碼中不存在的行。 – Michael

+0

我更新了代碼,現在錯誤文件中的行應與源代碼中的代碼相同 – Domi

+0

好吧,聽起來您需要在第一條指令之前聲明代碼段。查看彙編程序的手冊,瞭解完成的方式。 – Michael

回答

0

你缺少的。公司文件爲該處理器,你必須包含這樣的:

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你可以看到什麼配置位你們有您的處理器從菜單條下:窗口> PIC存儲器視圖>配置位 將它們添加到配置下這種形式