Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
this is a piece of code that I made and am getting errors 151 and 152 when I attempt to build in MPLab 8.63. My instructor and I cannot find the reason for this error! can anyone help

;**********************************************************************
;                                                                     *
;    Filename:       MOTOR_SPEED_CONTROL.asm                          *
;    Date:           FEBRUARY, 17 2011                                *
;    File Version:   VERSION 1                                        *
;                                                                     *
;    Author:         DANIEL COMTOIS                                   *
;    Company:        STUDENT                                          *
;                                                                     *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Files required: P16F84A.INC                                      *
;                                                                     *
;                                                                     *
;                                                                     *
;**********************************************************************
;                                                                     *
;    Notes:                                                           *
;                                                                     *
;                                                                     *
;                                                                     *
;                                                                     *
;**********************************************************************


    list      p=16F84A             ; list directive to define processor
    #include <p16F84a.inc>         ; processor specific variable definitions




    __CONFIG   _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC


COUNT1      equ 0X0C    ;First Counter for our dleay loops
COUNT2      equ 0X0D    ;Second counter for our delay loops


; '__CONFIG' directive is used to embed configuration data within .asm file.
; The lables following the directive are located in the respective .inc file.
; See respective data sheet for additional information on configuration word.

    goto main

;ISR

org     0x04




    comf    PORTA,1
    btfsc   PORTA,0
    goto    NO
    goto    YES
NO
    btfsc   PORTB,0
    goto    theend
    btfsc   PORTB,1
    goto    bit2
    goto    twenty



YES
    btfsc   PORTB,0
    goto    theend
    btfss   PORTB,1
    goto    twenty
    btfsc   PORTB,2
    goto    eighty
    goto    fifty

bit2
    btfsc   PORTB,2
    goto    eighty
    goto    fifty

eighty
    movlw   0xF4
    goto    timer

fifty
    movlw   0x39
    goto timer

twenty
    movlw   0x83
    goto timer


timer   movwf   TMR0
theend  bsf     INTCON,2 ;TOIF
        retfie




;**********************************************************************

main

;SET UP THE PORTS



    bsf     STATUS,5    ;Switch to Bank 1
    movlw   0XFE        ;SetUP Port A pins
    movwf   TRISA       ;to input.
    movlw   0xFF        ;SETUP PORT B PINS
    movwf   TRISB       ;TO INPUT
    movlw   0x07        ;Select prscaller 256
    movwf   OPTION_REG      ;EDGE SELECT BIT

    bcf     STATUS,5    ;Switch back to Bank 0


    bsf INTCON,7            ;ENABLE GLOBAL INTERUPT
    bsf INTCON,5            ;ENABLE TIMER0 OVERFLOW
    bsf INTCON,2            ;ENABLE TIMER0 OVERFLOW FLAG BIT



;Turn led on

Start

    btfsc   PORTB,0
    goto    Start
    bcf     PORTA,0


    goto    Start




;Delay Subroutine
Delay

Loop1   decfsz  COUNT1,1    ;THIS SECOND LOOP KEEPS THE LED TURNED ON
        goto    Loop1       ;long enough to see it
        decfsz  COUNT2,1
        goto    Loop1

    return

;END OF PROGRAM


END
                         ; directive 'end of program'


error while building

----------------------------------------------------------------------
Debug build of project `J:\MICRO_semester_2\LABS\MOTOR_SPEED_CONTROL\AGAIN\DAMNYOU.mcp' started.
Language tool versions: MPASMWIN.exe v5.39, mplink.exe v4.38, mplib.exe v4.38
Preprocessor symbol `__DEBUG' is defined.Wed Apr 06 17:05:29 2011
----------------------------------------------------------------------
Clean: Deleting intermediary and output files.
Clean: Deleted file "J:\MICRO_semester_2\LABS\MOTOR_SPEED_CONTROL\AGAIN\DAMNYOU.mcs".
Clean: Done.
Executing: "C:\Program Files (x86)\Microchip\MPASM Suite\MPASMWIN.exe" /q /p16F84A "FIRST.ASM" /l"FIRST.lst" /e"FIRST.err" /o"FIRST.o" /d__DEBUG=1
Error[151] J:\MICRO_SEMESTER_2\LABS\MOTOR_SPEED_CONTROL\AGAIN\FIRST.ASM 45 : Operand contains unresolvable labels or is too complex
Error[152] J:\MICRO_SEMESTER_2\LABS\MOTOR_SPEED_CONTROL\AGAIN\FIRST.ASM 45 : Executable code and data must be defined in an appropriate section
Warning[205] J:\MICRO_SEMESTER_2\LABS\MOTOR_SPEED_CONTROL\AGAIN\FIRST.ASM 49 : Found directive in column 1. (org)
Message[302] J:\MICRO_SEMESTER_2\LABS\MOTOR_SPEED_CONTROL\AGAIN\FIRST.ASM 111 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] J:\MICRO_SEMESTER_2\LABS\MOTOR_SPEED_CONTROL\AGAIN\FIRST.ASM 113 : Register in operand not in bank 0. Ensure that bank bits are correct.
Message[302] J:\MICRO_SEMESTER_2\LABS\MOTOR_SPEED_CONTROL\AGAIN\FIRST.ASM 115 : Register in operand not in bank 0. Ensure that bank bits are correct.
Warning[205] J:\MICRO_SEMESTER_2\LABS\MOTOR_SPEED_CONTROL\AGAIN\FIRST.ASM 153 : Found directive in column 1. (END)
Halting build on first failure as requested.
----------------------------------------------------------------------
Debug build of project `J:\MICRO_semester_2\LABS\MOTOR_SPEED_CONTROL\AGAIN\DAMNYOU.mcp' failed.
Language tool versions: MPASMWIN.exe v5.39, mplink.exe v4.38, mplib.exe v4.38
Preprocessor symbol `__DEBUG' is defined.Wed Apr 06 17:05:32 2011
----------------------------------------------------------------------
BUILD FAILED
Posted

1 solution

Disclaimer: I don't know assembly very well, so let me know if I'm wrong and I will delete this answer.

Seems the compiler doesn't like the "goto main". I see the label for "main" starts on the line previous to the first instruction under "main". This tutorial shows the instructions on the same line as the label. I'm not sure if that is a rule that the compiler is enforcing, but maybe.

Another idea: maybe one of the labels you are using is a reserved word?

My recommendation: make a smaller chunk of code and slowly add commands until you build all the way up to the program in your question. Eventually, something you add will cause the compiler to error out during the build. That is the something you need to focus on.
 
Share this answer
 
Comments
Daniel Comtois 6-Apr-11 19:07pm    
Thanks... I said the same thing to my instructor, and he laughed saying that I should learn how to spell. lol. I did get all the way to the end of the code to the end and then get the error. I will try again hopefully it will work!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900