EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

Need help with PIC Macros

Started by stephendbarnes April 16, 2003
Thank you. I have made a little progress. I found that the compiler
was only compiling the macros.inc file and stopping there! I'm new to
this and your comments about the .lst file made me go look at it!
WOW. It reported 0 program words used! Looking at the list I saw that
none of my code was present. The problem seemed to be that Karl
Lunt's macro file has the compiler directive "end" at the end. I
assume that this was causing the compiler to stop dead in its tracks.
I removed the "end" directive from the macro file and it compiled and
simulates. I do have a problem with the thing constantly going to the
first case "case 3" and ignoring the other two regardless of the
value W. I'll be looking forward to seeing your code. I will try
debugging this myself without yelling for help at every turn (jump in
with both feet and only yell when drowning!). You have been, and are
being, an enormous help. Thanks again.

Regards,
Steve

--- In , "rtstofer" <rstofer@p...> wrote:
> I finally figured out how to attach a zip file - I have to send it
by
> email to from my registered mail account.
I
> can't do it from work so I will post it tonight.
>
> I have a zip file with the .asm, .inc and related project files -
> known to work. Just extract to c:\test\ and open the project in
> MPASM IDE.
>
> I tried to create the failure you are having and can't seem to
> duplicate it. Once we are both working from the same files maybe
it
> will become clear. > --- In , "stephendbarnes"
> <stephendbarnes@h...> wrote:
> > I think I see what is happening but I don't know what to do about
> it.
> > The compiler is actually not looking at my code at all! When it
> gets
> > to the "#include macros.inc" it compiles the macros and skips the
> > rest of my source! If you would like to see the .lst I'll post it
> for
> > you to look at. Thanks again for your help.
> >
> > Regards,
> > Steve
> >
> > --- In , "rtstofer" <rstofer@p...> wrote:
> > >
> > > OOPS! Of course the new label in my prior message goes ahead of
> the
> > > MOVF PORTA,W. Comes from typing without thinking.
> > >
> > > --- In , "stephendbarnes"
> > > <stephendbarnes@h...> wrote:
> > > > Hello all,
> > > > I have been attempting to make use of Karl Lunt's PIC Macros
> with
> > > no
> > > > success
> > > > during the build phase. I have followed his instructions and
> > > emailed
> > > > him for
> > > > help with no response. I'm using MPLab 6.20 and writing some
> test
> > > > code for
> > > > the 16F84A. The
> > > > following text describes my code and the errors upon build.
> Could
> > > > anyone
> > > > take a look and see if you could provide some insight? Thanks
> in
> > > > advance for
> > > > any help.
> > > >
> > > > Regards,
> > > > Stephen D. Barnes
> > > >
> > > > My code follows:
> > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > ***
> > > > ERRORLEVEL -224 ; suppress message because of
> tris
> > > > ERRORLEVEL -302 ; suppress message because of
> > page
> > > > change
> > > >
> > > > list pF84A ; list directive to
> > define
> > > > processor
> > > > #include <p16F84A.inc> ; processor specific
variable
> > > > definitions
> > > > #include ".\macros.asm"
> > > >
> > > > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
> > > >
> > > > ; '__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.
> > > >
> > > >
> > >
> >
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > > ;;
> > > > ;;;;;;
> > > > ;;;;;;;;;;;;;;;;;
> > > > ORG 0x000 ; processor reset vector
> > > > goto Main ; go to beginning of program
> > >
> >
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > > ;;
> > > > ;;;;;;
> > > > ;;;;;;;;;;;;;;;;;
> > > >
> > >
> >
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > > ;;
> > > > ;;;;;;
> > > > ;;;;;;;;;;;;;;;;;
> > > > Main:
> > > > clrf PORTB ; PORTB all outputs cleared
> > > > bsf STATUS,5 ; Switch to Register Bank 1 for TRIS
> > > > movlw B'11111111' ; all bits high in W
> > > > movwf TRISA ; contents of W copied to
TRISA
> > > (PORTA
> > > > all
> > > > inputs)
> > > > movlw B'00000000' ; all bits low in W
> > > > movwf TRISB ; contents of W copied to
TRISB
> > > (PORTB
> > > > all
> > > > outputs)
> > > > movlw 0 ; 0 in W
> > > > movwf OPTION_REG ; contents of W copied to
OPTION_REG
> > > (Port
> > > > B
> > > >
pullups
> > > > enabled)
> > > > bcf STATUS,5 ; Switch back to Register Bank 0
> > > >
> > > > movf PORTA ,0 ; move PORTA bit 0 to W register
> > > >
> > > > case 3
> > > > call Reverse
> > > > endcase
> > > >
> > > > case 2
> > > > call Left
> > > > endcase
> > > >
> > > > case 1
> > > > call Right
> > > > endcase
> > > >
> > > > Reverse:
> > > > return
> > > > Left:
> > > > return
> > > > Right:
> > > > return
> > > >
> > > > end
> > > >
> > >
> >
>
**********************************************************************
> > > > ***
> > > >
> > > > When I build I get the following error:
> > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > ****
> > > > Executing: "E:\Program Files\MPLAB
> > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o"
> > > > Executing: "E:\Program Files\MPLAB
> > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o"
> > > > Skipping link step. The project contains no linker script.
> > > > BUILD FAILED
> > > >
> > >
> >
>
**********************************************************************
> > > > ****
> > > >
> > > > Soooo... I created a linker script conforming to MPASM spec
> which
> > > > reads as
> > > > follows and is part of the MPLab project:
> > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > ****
> > > > FILES macros.o test1.o
> > > >
> > >
> >
>
**********************************************************************
> > > > ****
> > > >
> > > > Build now reports the following error:
> > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > ****
> > > > Executing: "E:\Program Files\MPLAB
> > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o"
> > > > Executing: "E:\Program Files\MPLAB
> > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o"
> > > > Executing: "E:\Program Files\MPLAB
> > > > IDE\MCHIP_Tools\mplink.exe" "test1.lkr"
> > > > "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof"
> > > > MPLINK 3.30, Linker
> > > > Copyright (c) 2003 Microchip Technology Inc.
> > > > Error - section '.cinit' can not fit the section.
> Section '.cinit'
> > > > length=0x00000004
> > > > Errors : 1
> > > > BUILD FAILED
> > > >
> > >
> >
>
**********************************************************************
> > > > ****






We must have gotten different versions of the macros. Mine did not
have an 'end' statement but I was beginning to suspect that yours
did. That would be about the only reason for the assembler to stop
early.

I am not sure why your code would execute any case. In my version of
SIM without a stimulus file the value of PORTA is always 0. This
should not execute any case and if you have placed a goto loop
statement following endselect you should not fall into the reverse
subroutine. The label 'loop' should be before the movwf PORTA,W

An easy way to trace this code is to put a movlw 3 (or something)
immediately after the movwf PORTA,W. This will load W with a
matching value for one of the various cases. I would still mask off
the unused bits and change the select and case statements as
discussed previously.

--- In , "stephendbarnes"
<stephendbarnes@h...> wrote:
> Thank you. I have made a little progress. I found that the compiler
> was only compiling the macros.inc file and stopping there! I'm new
to
> this and your comments about the .lst file made me go look at it!
> WOW. It reported 0 program words used! Looking at the list I saw
that
> none of my code was present. The problem seemed to be that Karl
> Lunt's macro file has the compiler directive "end" at the end. I
> assume that this was causing the compiler to stop dead in its
tracks.
> I removed the "end" directive from the macro file and it compiled
and
> simulates. I do have a problem with the thing constantly going to
the
> first case "case 3" and ignoring the other two regardless of the
> value W. I'll be looking forward to seeing your code. I will try
> debugging this myself without yelling for help at every turn (jump
in
> with both feet and only yell when drowning!). You have been, and
are
> being, an enormous help. Thanks again.
>
> Regards,
> Steve
>
> --- In , "rtstofer" <rstofer@p...> wrote:
> > I finally figured out how to attach a zip file - I have to send
it
> by
> > email to from my registered mail
account.
> I
> > can't do it from work so I will post it tonight.
> >
> > I have a zip file with the .asm, .inc and related project files -
> > known to work. Just extract to c:\test\ and open the project in
> > MPASM IDE.
> >
> > I tried to create the failure you are having and can't seem to
> > duplicate it. Once we are both working from the same files maybe
> it
> > will become clear.
> >
> >
> > --- In , "stephendbarnes"
> > <stephendbarnes@h...> wrote:
> > > I think I see what is happening but I don't know what to do
about
> > it.
> > > The compiler is actually not looking at my code at all! When it
> > gets
> > > to the "#include macros.inc" it compiles the macros and skips
the
> > > rest of my source! If you would like to see the .lst I'll post
it
> > for
> > > you to look at. Thanks again for your help.
> > >
> > > Regards,
> > > Steve
> > >
> > > --- In , "rtstofer" <rstofer@p...> wrote:
> > > >
> > > > OOPS! Of course the new label in my prior message goes ahead
of
> > the
> > > > MOVF PORTA,W. Comes from typing without thinking.
> > > >
> > > > --- In , "stephendbarnes"
> > > > <stephendbarnes@h...> wrote:
> > > > > Hello all,
> > > > > I have been attempting to make use of Karl Lunt's PIC
Macros
> > with
> > > > no
> > > > > success
> > > > > during the build phase. I have followed his instructions
and
> > > > emailed
> > > > > him for
> > > > > help with no response. I'm using MPLab 6.20 and writing
some
> > test
> > > > > code for
> > > > > the 16F84A. The
> > > > > following text describes my code and the errors upon build.
> > Could
> > > > > anyone
> > > > > take a look and see if you could provide some insight?
Thanks
> > in
> > > > > advance for
> > > > > any help.
> > > > >
> > > > > Regards,
> > > > > Stephen D. Barnes
> > > > >
> > > > > My code follows:
> > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > ***
> > > > > ERRORLEVEL -224 ; suppress message because
of
> > tris
> > > > > ERRORLEVEL -302 ; suppress message because
of
> > > page
> > > > > change
> > > > >
> > > > > list pF84A ; list directive
to
> > > define
> > > > > processor
> > > > > #include <p16F84A.inc> ; processor specific
> variable
> > > > > definitions
> > > > > #include ".\macros.asm"
> > > > >
> > > > > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
> > > > >
> > > > > ; '__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.
> > > > >
> > > > >
> > > >
> > >
> >
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > > > ;;
> > > > > ;;;;;;
> > > > > ;;;;;;;;;;;;;;;;;
> > > > > ORG 0x000 ; processor reset vector
> > > > > goto Main ; go to beginning of program
> > > >
> > >
> >
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > > > ;;
> > > > > ;;;;;;
> > > > > ;;;;;;;;;;;;;;;;;
> > > > >
> > > >
> > >
> >
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > > > ;;
> > > > > ;;;;;;
> > > > > ;;;;;;;;;;;;;;;;;
> > > > > Main:
> > > > > clrf PORTB ; PORTB all outputs cleared
> > > > > bsf STATUS,5 ; Switch to Register Bank 1 for TRIS
> > > > > movlw B'11111111' ; all bits high in W
> > > > > movwf TRISA ; contents of W copied to
> TRISA
> > > > (PORTA
> > > > > all
> > > > > inputs)
> > > > > movlw B'00000000' ; all bits low in W
> > > > > movwf TRISB ; contents of W copied to
> TRISB
> > > > (PORTB
> > > > > all
> > > > > outputs)
> > > > > movlw 0 ; 0 in W
> > > > > movwf OPTION_REG ; contents of W copied to
> OPTION_REG
> > > > (Port
> > > > > B
> > > > >
> pullups
> > > > > enabled)
> > > > > bcf STATUS,5 ; Switch back to Register Bank 0
> > > > >
> > > > > movf PORTA ,0 ; move PORTA bit 0 to W register
> > > > >
> > > > > case 3
> > > > > call Reverse
> > > > > endcase
> > > > >
> > > > > case 2
> > > > > call Left
> > > > > endcase
> > > > >
> > > > > case 1
> > > > > call Right
> > > > > endcase
> > > > >
> > > > > Reverse:
> > > > > return
> > > > > Left:
> > > > > return
> > > > > Right:
> > > > > return
> > > > >
> > > > > end
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > ***
> > > > >
> > > > > When I build I get the following error:
> > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > ****
> > > > > Executing: "E:\Program Files\MPLAB
> > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o"
> > > > > Executing: "E:\Program Files\MPLAB
> > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o"
> > > > > Skipping link step. The project contains no linker script.
> > > > > BUILD FAILED
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > ****
> > > > >
> > > > > Soooo... I created a linker script conforming to MPASM spec
> > which
> > > > > reads as
> > > > > follows and is part of the MPLab project:
> > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > ****
> > > > > FILES macros.o test1.o
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > ****
> > > > >
> > > > > Build now reports the following error:
> > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > ****
> > > > > Executing: "E:\Program Files\MPLAB
> > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o"
> > > > > Executing: "E:\Program Files\MPLAB
> > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o"
> > > > > Executing: "E:\Program Files\MPLAB
> > > > > IDE\MCHIP_Tools\mplink.exe" "test1.lkr"
> > > > > "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof"
> > > > > MPLINK 3.30, Linker
> > > > > Copyright (c) 2003 Microchip Technology Inc.
> > > > > Error - section '.cinit' can not fit the section.
> > Section '.cinit'
> > > > > length=0x00000004
> > > > > Errors : 1
> > > > > BUILD FAILED
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > ****






Just to check the version of the macros, look at nextf and it should
look like this (after I revised it):

nextf...macro..var,incf
_nxtknt.set...._nxtknt-1
........movf...incf,w..; the code was incorrect here
........addwf..var,f...; leave the result in var, not incf
........goto..._for#v(_nxtknt)
_next#v(_nxtknt)
........endm

--- In , "rtstofer" <rstofer@p...> wrote:
>
> We must have gotten different versions of the macros. Mine did not
> have an 'end' statement but I was beginning to suspect that yours
> did. That would be about the only reason for the assembler to stop
> early.
>
> I am not sure why your code would execute any case. In my version
of
> SIM without a stimulus file the value of PORTA is always 0. This
> should not execute any case and if you have placed a goto loop
> statement following endselect you should not fall into the reverse
> subroutine. The label 'loop' should be before the movwf PORTA,W
>
> An easy way to trace this code is to put a movlw 3 (or something)
> immediately after the movwf PORTA,W. This will load W with a
> matching value for one of the various cases. I would still mask
off
> the unused bits and change the select and case statements as
> discussed previously.
>
> --- In , "stephendbarnes"
> <stephendbarnes@h...> wrote:
> > Thank you. I have made a little progress. I found that the
compiler
> > was only compiling the macros.inc file and stopping there! I'm
new
> to
> > this and your comments about the .lst file made me go look at it!
> > WOW. It reported 0 program words used! Looking at the list I saw
> that
> > none of my code was present. The problem seemed to be that Karl
> > Lunt's macro file has the compiler directive "end" at the end. I
> > assume that this was causing the compiler to stop dead in its
> tracks.
> > I removed the "end" directive from the macro file and it compiled
> and
> > simulates. I do have a problem with the thing constantly going to
> the
> > first case "case 3" and ignoring the other two regardless of the
> > value W. I'll be looking forward to seeing your code. I will try
> > debugging this myself without yelling for help at every turn
(jump
> in
> > with both feet and only yell when drowning!). You have been, and
> are
> > being, an enormous help. Thanks again.
> >
> > Regards,
> > Steve
> >
> > --- In , "rtstofer" <rstofer@p...> wrote:
> > > I finally figured out how to attach a zip file - I have to send
> it
> > by
> > > email to from my registered mail
> account.
> > I
> > > can't do it from work so I will post it tonight.
> > >
> > > I have a zip file with the .asm, .inc and related project
files -
> > > known to work. Just extract to c:\test\ and open the project
in
> > > MPASM IDE.
> > >
> > > I tried to create the failure you are having and can't seem to
> > > duplicate it. Once we are both working from the same files
maybe
> > it
> > > will become clear.
> > >
> > >
> > > --- In , "stephendbarnes"
> > > <stephendbarnes@h...> wrote:
> > > > I think I see what is happening but I don't know what to do
> about
> > > it.
> > > > The compiler is actually not looking at my code at all! When
it
> > > gets
> > > > to the "#include macros.inc" it compiles the macros and skips
> the
> > > > rest of my source! If you would like to see the .lst I'll
post
> it
> > > for
> > > > you to look at. Thanks again for your help.
> > > >
> > > > Regards,
> > > > Steve
> > > >
> > > > --- In , "rtstofer" <rstofer@p...>
wrote:
> > > > >
> > > > > OOPS! Of course the new label in my prior message goes
ahead
> of
> > > the
> > > > > MOVF PORTA,W. Comes from typing without thinking.
> > > > >
> > > > > --- In , "stephendbarnes"
> > > > > <stephendbarnes@h...> wrote:
> > > > > > Hello all,
> > > > > > I have been attempting to make use of Karl Lunt's PIC
> Macros
> > > with
> > > > > no
> > > > > > success
> > > > > > during the build phase. I have followed his instructions
> and
> > > > > emailed
> > > > > > him for
> > > > > > help with no response. I'm using MPLab 6.20 and writing
> some
> > > test
> > > > > > code for
> > > > > > the 16F84A. The
> > > > > > following text describes my code and the errors upon
build.
> > > Could
> > > > > > anyone
> > > > > > take a look and see if you could provide some insight?
> Thanks
> > > in
> > > > > > advance for
> > > > > > any help.
> > > > > >
> > > > > > Regards,
> > > > > > Stephen D. Barnes
> > > > > >
> > > > > > My code follows:
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > ***
> > > > > > ERRORLEVEL -224 ; suppress message
because
> of
> > > tris
> > > > > > ERRORLEVEL -302 ; suppress message
because
> of
> > > > page
> > > > > > change
> > > > > >
> > > > > > list pF84A ; list
directive
> to
> > > > define
> > > > > > processor
> > > > > > #include <p16F84A.inc> ; processor specific
> > variable
> > > > > > definitions
> > > > > > #include ".\macros.asm"
> > > > > >
> > > > > > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
> > > > > >
> > > > > > ; '__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.
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > > > > ;;
> > > > > > ;;;;;;
> > > > > > ;;;;;;;;;;;;;;;;;
> > > > > > ORG 0x000 ; processor reset vector
> > > > > > goto Main ; go to beginning of program
> > > > >
> > > >
> > >
> >
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > > > > ;;
> > > > > > ;;;;;;
> > > > > > ;;;;;;;;;;;;;;;;;
> > > > > >
> > > > >
> > > >
> > >
> >
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > > > > ;;
> > > > > > ;;;;;;
> > > > > > ;;;;;;;;;;;;;;;;;
> > > > > > Main:
> > > > > > clrf PORTB ; PORTB all outputs cleared
> > > > > > bsf STATUS,5 ; Switch to Register Bank 1 for
TRIS
> > > > > > movlw B'11111111' ; all bits high in W
> > > > > > movwf TRISA ; contents of W copied to
> > TRISA
> > > > > (PORTA
> > > > > > all
> > > > > > inputs)
> > > > > > movlw B'00000000' ; all bits low in W
> > > > > > movwf TRISB ; contents of W copied to
> > TRISB
> > > > > (PORTB
> > > > > > all
> > > > > > outputs)
> > > > > > movlw 0 ; 0 in W
> > > > > > movwf OPTION_REG ; contents of W copied to
> > OPTION_REG
> > > > > (Port
> > > > > > B
> > > > > >
> > pullups
> > > > > > enabled)
> > > > > > bcf STATUS,5 ; Switch back to Register Bank 0
> > > > > >
> > > > > > movf PORTA ,0 ; move PORTA bit 0 to W register
> > > > > >
> > > > > > case 3
> > > > > > call Reverse
> > > > > > endcase
> > > > > >
> > > > > > case 2
> > > > > > call Left
> > > > > > endcase
> > > > > >
> > > > > > case 1
> > > > > > call Right
> > > > > > endcase
> > > > > >
> > > > > > Reverse:
> > > > > > return
> > > > > > Left:
> > > > > > return
> > > > > > Right:
> > > > > > return
> > > > > >
> > > > > > end
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > ***
> > > > > >
> > > > > > When I build I get the following error:
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > ****
> > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o"
> > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o"
> > > > > > Skipping link step. The project contains no linker
script.
> > > > > > BUILD FAILED
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > ****
> > > > > >
> > > > > > Soooo... I created a linker script conforming to MPASM
spec
> > > which
> > > > > > reads as
> > > > > > follows and is part of the MPLab project:
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > ****
> > > > > > FILES macros.o test1.o
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > ****
> > > > > >
> > > > > > Build now reports the following error:
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > ****
> > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o"
> > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o"
> > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > IDE\MCHIP_Tools\mplink.exe" "test1.lkr"
> > > > > > "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof"
> > > > > > MPLINK 3.30, Linker
> > > > > > Copyright (c) 2003 Microchip Technology Inc.
> > > > > > Error - section '.cinit' can not fit the section.
> > > Section '.cinit'
> > > > > > length=0x00000004
> > > > > > Errors : 1
> > > > > > BUILD FAILED
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > ****





Mine looks like this:

nextf...macro...var,incf
_nxtknt.set....._nxtknt-1
........movf....var,w
........addwf...incf,f
........goto...._for#v(_nxtknt)
_next#v(_nxtknt)
........endm
--- In , "rtstofer" <rstofer@p...> wrote:
>
> Just to check the version of the macros, look at nextf and it
should
> look like this (after I revised it):
>
> nextf...macro..var,incf
> _nxtknt.set...._nxtknt-1
> ........movf...incf,w..; the code was incorrect here
> ........addwf..var,f...; leave the result in var, not incf
> ........goto..._for#v(_nxtknt)
> _next#v(_nxtknt)
> ........endm
>
> --- In , "rtstofer" <rstofer@p...> wrote:
> >
> > We must have gotten different versions of the macros. Mine did
not
> > have an 'end' statement but I was beginning to suspect that yours
> > did. That would be about the only reason for the assembler to
stop
> > early.
> >
> > I am not sure why your code would execute any case. In my
version
> of
> > SIM without a stimulus file the value of PORTA is always 0. This
> > should not execute any case and if you have placed a goto loop
> > statement following endselect you should not fall into the
reverse
> > subroutine. The label 'loop' should be before the movwf PORTA,W
> >
> > An easy way to trace this code is to put a movlw 3 (or something)
> > immediately after the movwf PORTA,W. This will load W with a
> > matching value for one of the various cases. I would still mask
> off
> > the unused bits and change the select and case statements as
> > discussed previously.
> >
> > --- In , "stephendbarnes"
> > <stephendbarnes@h...> wrote:
> > > Thank you. I have made a little progress. I found that the
> compiler
> > > was only compiling the macros.inc file and stopping there! I'm
> new
> > to
> > > this and your comments about the .lst file made me go look at
it!
> > > WOW. It reported 0 program words used! Looking at the list I
saw
> > that
> > > none of my code was present. The problem seemed to be that Karl
> > > Lunt's macro file has the compiler directive "end" at the end.
I
> > > assume that this was causing the compiler to stop dead in its
> > tracks.
> > > I removed the "end" directive from the macro file and it
compiled
> > and
> > > simulates. I do have a problem with the thing constantly going
to
> > the
> > > first case "case 3" and ignoring the other two regardless of
the
> > > value W. I'll be looking forward to seeing your code. I will
try
> > > debugging this myself without yelling for help at every turn
> (jump
> > in
> > > with both feet and only yell when drowning!). You have been,
and
> > are
> > > being, an enormous help. Thanks again.
> > >
> > > Regards,
> > > Steve
> > >
> > > --- In , "rtstofer" <rstofer@p...> wrote:
> > > > I finally figured out how to attach a zip file - I have to
send
> > it
> > > by
> > > > email to from my registered mail
> > account.
> > > I
> > > > can't do it from work so I will post it tonight.
> > > >
> > > > I have a zip file with the .asm, .inc and related project
> files -
> > > > known to work. Just extract to c:\test\ and open the project
> in
> > > > MPASM IDE.
> > > >
> > > > I tried to create the failure you are having and can't seem
to
> > > > duplicate it. Once we are both working from the same files
> maybe
> > > it
> > > > will become clear.
> > > >
> > > >
> > > > --- In , "stephendbarnes"
> > > > <stephendbarnes@h...> wrote:
> > > > > I think I see what is happening but I don't know what to do
> > about
> > > > it.
> > > > > The compiler is actually not looking at my code at all!
When
> it
> > > > gets
> > > > > to the "#include macros.inc" it compiles the macros and
skips
> > the
> > > > > rest of my source! If you would like to see the .lst I'll
> post
> > it
> > > > for
> > > > > you to look at. Thanks again for your help.
> > > > >
> > > > > Regards,
> > > > > Steve
> > > > >
> > > > > --- In , "rtstofer" <rstofer@p...>
> wrote:
> > > > > >
> > > > > > OOPS! Of course the new label in my prior message goes
> ahead
> > of
> > > > the
> > > > > > MOVF PORTA,W. Comes from typing without thinking.
> > > > > >
> > > > > > --- In , "stephendbarnes"
> > > > > > <stephendbarnes@h...> wrote:
> > > > > > > Hello all,
> > > > > > > I have been attempting to make use of Karl Lunt's PIC
> > Macros
> > > > with
> > > > > > no
> > > > > > > success
> > > > > > > during the build phase. I have followed his
instructions
> > and
> > > > > > emailed
> > > > > > > him for
> > > > > > > help with no response. I'm using MPLab 6.20 and writing
> > some
> > > > test
> > > > > > > code for
> > > > > > > the 16F84A. The
> > > > > > > following text describes my code and the errors upon
> build.
> > > > Could
> > > > > > > anyone
> > > > > > > take a look and see if you could provide some insight?
> > Thanks
> > > > in
> > > > > > > advance for
> > > > > > > any help.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Stephen D. Barnes
> > > > > > >
> > > > > > > My code follows:
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > ***
> > > > > > > ERRORLEVEL -224 ; suppress message
> because
> > of
> > > > tris
> > > > > > > ERRORLEVEL -302 ; suppress message
> because
> > of
> > > > > page
> > > > > > > change
> > > > > > >
> > > > > > > list pF84A ; list
> directive
> > to
> > > > > define
> > > > > > > processor
> > > > > > > #include <p16F84A.inc> ; processor specific
> > > variable
> > > > > > > definitions
> > > > > > > #include ".\macros.asm"
> > > > > > >
> > > > > > > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON & _XT_OSC
> > > > > > >
> > > > > > > ; '__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.
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > > > > > ;;
> > > > > > > ;;;;;;
> > > > > > > ;;;;;;;;;;;;;;;;;
> > > > > > > ORG 0x000 ; processor reset vector
> > > > > > > goto Main ; go to beginning of program
> > > > > >
> > > > >
> > > >
> > >
> >
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > > > > > ;;
> > > > > > > ;;;;;;
> > > > > > > ;;;;;;;;;;;;;;;;;
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > > > > > ;;
> > > > > > > ;;;;;;
> > > > > > > ;;;;;;;;;;;;;;;;;
> > > > > > > Main:
> > > > > > > clrf PORTB ; PORTB all outputs
cleared
> > > > > > > bsf STATUS,5 ; Switch to Register Bank 1 for
> TRIS
> > > > > > > movlw B'11111111' ; all bits high in W
> > > > > > > movwf TRISA ; contents of W copied
to
> > > TRISA
> > > > > > (PORTA
> > > > > > > all
> > > > > > > inputs)
> > > > > > > movlw B'00000000' ; all bits low in W
> > > > > > > movwf TRISB ; contents of W copied
to
> > > TRISB
> > > > > > (PORTB
> > > > > > > all
> > > > > > > outputs)
> > > > > > > movlw 0 ; 0 in W
> > > > > > > movwf OPTION_REG ; contents of W copied to
> > > OPTION_REG
> > > > > > (Port
> > > > > > > B
> > > > > > >
> > > pullups
> > > > > > > enabled)
> > > > > > > bcf STATUS,5 ; Switch back to Register
Bank 0
> > > > > > >
> > > > > > > movf PORTA ,0 ; move PORTA bit 0 to W register
> > > > > > >
> > > > > > > case 3
> > > > > > > call Reverse
> > > > > > > endcase
> > > > > > >
> > > > > > > case 2
> > > > > > > call Left
> > > > > > > endcase
> > > > > > >
> > > > > > > case 1
> > > > > > > call Right
> > > > > > > endcase
> > > > > > >
> > > > > > > Reverse:
> > > > > > > return
> > > > > > > Left:
> > > > > > > return
> > > > > > > Right:
> > > > > > > return
> > > > > > >
> > > > > > > end
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > ***
> > > > > > >
> > > > > > > When I build I get the following error:
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > ****
> > > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o"
> > > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o"
> > > > > > > Skipping link step. The project contains no linker
> script.
> > > > > > > BUILD FAILED
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > ****
> > > > > > >
> > > > > > > Soooo... I created a linker script conforming to MPASM
> spec
> > > > which
> > > > > > > reads as
> > > > > > > follows and is part of the MPLab project:
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > ****
> > > > > > > FILES macros.o test1.o
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > ****
> > > > > > >
> > > > > > > Build now reports the following error:
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > ****
> > > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o"
> > > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o"
> > > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > > IDE\MCHIP_Tools\mplink.exe" "test1.lkr"
> > > > > > > "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof"
> > > > > > > MPLINK 3.30, Linker
> > > > > > > Copyright (c) 2003 Microchip Technology Inc.
> > > > > > > Error - section '.cinit' can not fit the section.
> > > > Section '.cinit'
> > > > > > > length=0x00000004
> > > > > > > Errors : 1
> > > > > > > BUILD FAILED
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > ****






This will be a problem. The code is loading the loop variable 'var'
into W and then adding 'incf' and leaving the result in 'incf'. It
needs to be stored in 'var' as in my previous post.

At some point you may want to correct your version. Maybe write a
small program and test that it works.

--- In , "stephendbarnes"
<stephendbarnes@h...> wrote:
> Mine looks like this:
>
> nextf...macro...var,incf
> _nxtknt.set....._nxtknt-1
> ........movf....var,w
> ........addwf...incf,f
> ........goto...._for#v(_nxtknt)
> _next#v(_nxtknt)
> ........endm >
> --- In , "rtstofer" <rstofer@p...> wrote:
> >
> > Just to check the version of the macros, look at nextf and it
> should
> > look like this (after I revised it):
> >
> > nextf...macro..var,incf
> > _nxtknt.set...._nxtknt-1
> > ........movf...incf,w..; the code was incorrect here
> > ........addwf..var,f...; leave the result in var, not incf
> > ........goto..._for#v(_nxtknt)
> > _next#v(_nxtknt)
> > ........endm
> >
> > --- In , "rtstofer" <rstofer@p...> wrote:
> > >
> > > We must have gotten different versions of the macros. Mine did
> not
> > > have an 'end' statement but I was beginning to suspect that
yours
> > > did. That would be about the only reason for the assembler to
> stop
> > > early.
> > >
> > > I am not sure why your code would execute any case. In my
> version
> > of
> > > SIM without a stimulus file the value of PORTA is always 0.
This
> > > should not execute any case and if you have placed a goto loop
> > > statement following endselect you should not fall into the
> reverse
> > > subroutine. The label 'loop' should be before the movwf PORTA,W
> > >
> > > An easy way to trace this code is to put a movlw 3 (or
something)
> > > immediately after the movwf PORTA,W. This will load W with a
> > > matching value for one of the various cases. I would still
mask
> > off
> > > the unused bits and change the select and case statements as
> > > discussed previously.
> > >
> > > --- In , "stephendbarnes"
> > > <stephendbarnes@h...> wrote:
> > > > Thank you. I have made a little progress. I found that the
> > compiler
> > > > was only compiling the macros.inc file and stopping there!
I'm
> > new
> > > to
> > > > this and your comments about the .lst file made me go look at
> it!
> > > > WOW. It reported 0 program words used! Looking at the list I
> saw
> > > that
> > > > none of my code was present. The problem seemed to be that
Karl
> > > > Lunt's macro file has the compiler directive "end" at the
end.
> I
> > > > assume that this was causing the compiler to stop dead in its
> > > tracks.
> > > > I removed the "end" directive from the macro file and it
> compiled
> > > and
> > > > simulates. I do have a problem with the thing constantly
going
> to
> > > the
> > > > first case "case 3" and ignoring the other two regardless of
> the
> > > > value W. I'll be looking forward to seeing your code. I will
> try
> > > > debugging this myself without yelling for help at every turn
> > (jump
> > > in
> > > > with both feet and only yell when drowning!). You have been,
> and
> > > are
> > > > being, an enormous help. Thanks again.
> > > >
> > > > Regards,
> > > > Steve
> > > >
> > > > --- In , "rtstofer" <rstofer@p...>
wrote:
> > > > > I finally figured out how to attach a zip file - I have to
> send
> > > it
> > > > by
> > > > > email to from my registered mail
> > > account.
> > > > I
> > > > > can't do it from work so I will post it tonight.
> > > > >
> > > > > I have a zip file with the .asm, .inc and related project
> > files -
> > > > > known to work. Just extract to c:\test\ and open the
project
> > in
> > > > > MPASM IDE.
> > > > >
> > > > > I tried to create the failure you are having and can't seem
> to
> > > > > duplicate it. Once we are both working from the same files
> > maybe
> > > > it
> > > > > will become clear.
> > > > >
> > > > >
> > > > > --- In , "stephendbarnes"
> > > > > <stephendbarnes@h...> wrote:
> > > > > > I think I see what is happening but I don't know what to
do
> > > about
> > > > > it.
> > > > > > The compiler is actually not looking at my code at all!
> When
> > it
> > > > > gets
> > > > > > to the "#include macros.inc" it compiles the macros and
> skips
> > > the
> > > > > > rest of my source! If you would like to see the .lst I'll
> > post
> > > it
> > > > > for
> > > > > > you to look at. Thanks again for your help.
> > > > > >
> > > > > > Regards,
> > > > > > Steve
> > > > > >
> > > > > > --- In , "rtstofer" <rstofer@p...>
> > wrote:
> > > > > > >
> > > > > > > OOPS! Of course the new label in my prior message goes
> > ahead
> > > of
> > > > > the
> > > > > > > MOVF PORTA,W. Comes from typing without thinking.
> > > > > > >
> > > > > > > --- In , "stephendbarnes"
> > > > > > > <stephendbarnes@h...> wrote:
> > > > > > > > Hello all,
> > > > > > > > I have been attempting to make use of Karl Lunt's PIC
> > > Macros
> > > > > with
> > > > > > > no
> > > > > > > > success
> > > > > > > > during the build phase. I have followed his
> instructions
> > > and
> > > > > > > emailed
> > > > > > > > him for
> > > > > > > > help with no response. I'm using MPLab 6.20 and
writing
> > > some
> > > > > test
> > > > > > > > code for
> > > > > > > > the 16F84A. The
> > > > > > > > following text describes my code and the errors upon
> > build.
> > > > > Could
> > > > > > > > anyone
> > > > > > > > take a look and see if you could provide some
insight?
> > > Thanks
> > > > > in
> > > > > > > > advance for
> > > > > > > > any help.
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Stephen D. Barnes
> > > > > > > >
> > > > > > > > My code follows:
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > ***
> > > > > > > > ERRORLEVEL -224 ; suppress message
> > because
> > > of
> > > > > tris
> > > > > > > > ERRORLEVEL -302 ; suppress message
> > because
> > > of
> > > > > > page
> > > > > > > > change
> > > > > > > >
> > > > > > > > list pF84A ; list
> > directive
> > > to
> > > > > > define
> > > > > > > > processor
> > > > > > > > #include <p16F84A.inc> ; processor specific
> > > > variable
> > > > > > > > definitions
> > > > > > > > #include ".\macros.asm"
> > > > > > > >
> > > > > > > > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON &
_XT_OSC
> > > > > > > >
> > > > > > > > ; '__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.
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > > > > > > ;;
> > > > > > > > ;;;;;;
> > > > > > > > ;;;;;;;;;;;;;;;;;
> > > > > > > > ORG 0x000 ; processor reset vector
> > > > > > > > goto Main ; go to beginning of program
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > > > > > > ;;
> > > > > > > > ;;;;;;
> > > > > > > > ;;;;;;;;;;;;;;;;;
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > > > > > > ;;
> > > > > > > > ;;;;;;
> > > > > > > > ;;;;;;;;;;;;;;;;;
> > > > > > > > Main:
> > > > > > > > clrf PORTB ; PORTB all outputs
> cleared
> > > > > > > > bsf STATUS,5 ; Switch to Register Bank 1
for
> > TRIS
> > > > > > > > movlw B'11111111' ; all bits high in W
> > > > > > > > movwf TRISA ; contents of W copied
> to
> > > > TRISA
> > > > > > > (PORTA
> > > > > > > > all
> > > > > > > > inputs)
> > > > > > > > movlw B'00000000' ; all bits low in W
> > > > > > > > movwf TRISB ; contents of W copied
> to
> > > > TRISB
> > > > > > > (PORTB
> > > > > > > > all
> > > > > > > > outputs)
> > > > > > > > movlw 0 ; 0 in W
> > > > > > > > movwf OPTION_REG ; contents of W copied to
> > > > OPTION_REG
> > > > > > > (Port
> > > > > > > > B
> > > > > > > >
> > > >
pullups
> > > > > > > > enabled)
> > > > > > > > bcf STATUS,5 ; Switch back to Register
> Bank 0
> > > > > > > >
> > > > > > > > movf PORTA ,0 ; move PORTA bit 0 to W
register
> > > > > > > >
> > > > > > > > case 3
> > > > > > > > call Reverse
> > > > > > > > endcase
> > > > > > > >
> > > > > > > > case 2
> > > > > > > > call Left
> > > > > > > > endcase
> > > > > > > >
> > > > > > > > case 1
> > > > > > > > call Right
> > > > > > > > endcase
> > > > > > > >
> > > > > > > > Reverse:
> > > > > > > > return
> > > > > > > > Left:
> > > > > > > > return
> > > > > > > > Right:
> > > > > > > > return
> > > > > > > >
> > > > > > > > end
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > ***
> > > > > > > >
> > > > > > > > When I build I get the following error:
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > ****
> > > > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o"
> > > > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > > >
> "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o"
> > > > > > > > Skipping link step. The project contains no linker
> > script.
> > > > > > > > BUILD FAILED
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > ****
> > > > > > > >
> > > > > > > > Soooo... I created a linker script conforming to
MPASM
> > spec
> > > > > which
> > > > > > > > reads as
> > > > > > > > follows and is part of the MPLab project:
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > ****
> > > > > > > > FILES macros.o test1.o
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > ****
> > > > > > > >
> > > > > > > > Build now reports the following error:
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > ****
> > > > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o"
> > > > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > > >
> "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o"
> > > > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > > > IDE\MCHIP_Tools\mplink.exe" "test1.lkr"
> > > > > > > > "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof"
> > > > > > > > MPLINK 3.30, Linker
> > > > > > > > Copyright (c) 2003 Microchip Technology Inc.
> > > > > > > > Error - section '.cinit' can not fit the section.
> > > > > Section '.cinit'
> > > > > > > > length=0x00000004
> > > > > > > > Errors : 1
> > > > > > > > BUILD FAILED
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > ****





I changed it to match your example and I'm ready to start debugging
again!
Thanks a million!

Regards,
Steve

--- In , "rtstofer" <rstofer@p...> wrote:
>
> This will be a problem. The code is loading the loop
variable 'var'
> into W and then adding 'incf' and leaving the result in 'incf'. It
> needs to be stored in 'var' as in my previous post.
>
> At some point you may want to correct your version. Maybe write a
> small program and test that it works.
>
> --- In , "stephendbarnes"
> <stephendbarnes@h...> wrote:
> > Mine looks like this:
> >
> > nextf...macro...var,incf
> > _nxtknt.set....._nxtknt-1
> > ........movf....var,w
> > ........addwf...incf,f
> > ........goto...._for#v(_nxtknt)
> > _next#v(_nxtknt)
> > ........endm
> >
> >
> >
> > --- In , "rtstofer" <rstofer@p...> wrote:
> > >
> > > Just to check the version of the macros, look at nextf and it
> > should
> > > look like this (after I revised it):
> > >
> > > nextf...macro..var,incf
> > > _nxtknt.set...._nxtknt-1
> > > ........movf...incf,w..; the code was incorrect here
> > > ........addwf..var,f...; leave the result in var, not incf
> > > ........goto..._for#v(_nxtknt)
> > > _next#v(_nxtknt)
> > > ........endm
> > >
> > > --- In , "rtstofer" <rstofer@p...> wrote:
> > > >
> > > > We must have gotten different versions of the macros. Mine
did
> > not
> > > > have an 'end' statement but I was beginning to suspect that
> yours
> > > > did. That would be about the only reason for the assembler
to
> > stop
> > > > early.
> > > >
> > > > I am not sure why your code would execute any case. In my
> > version
> > > of
> > > > SIM without a stimulus file the value of PORTA is always 0.
> This
> > > > should not execute any case and if you have placed a goto
loop
> > > > statement following endselect you should not fall into the
> > reverse
> > > > subroutine. The label 'loop' should be before the movwf
PORTA,W
> > > >
> > > > An easy way to trace this code is to put a movlw 3 (or
> something)
> > > > immediately after the movwf PORTA,W. This will load W with a
> > > > matching value for one of the various cases. I would still
> mask
> > > off
> > > > the unused bits and change the select and case statements as
> > > > discussed previously.
> > > >
> > > > --- In , "stephendbarnes"
> > > > <stephendbarnes@h...> wrote:
> > > > > Thank you. I have made a little progress. I found that the
> > > compiler
> > > > > was only compiling the macros.inc file and stopping there!
> I'm
> > > new
> > > > to
> > > > > this and your comments about the .lst file made me go look
at
> > it!
> > > > > WOW. It reported 0 program words used! Looking at the list
I
> > saw
> > > > that
> > > > > none of my code was present. The problem seemed to be that
> Karl
> > > > > Lunt's macro file has the compiler directive "end" at the
> end.
> > I
> > > > > assume that this was causing the compiler to stop dead in
its
> > > > tracks.
> > > > > I removed the "end" directive from the macro file and it
> > compiled
> > > > and
> > > > > simulates. I do have a problem with the thing constantly
> going
> > to
> > > > the
> > > > > first case "case 3" and ignoring the other two regardless
of
> > the
> > > > > value W. I'll be looking forward to seeing your code. I
will
> > try
> > > > > debugging this myself without yelling for help at every
turn
> > > (jump
> > > > in
> > > > > with both feet and only yell when drowning!). You have
been,
> > and
> > > > are
> > > > > being, an enormous help. Thanks again.
> > > > >
> > > > > Regards,
> > > > > Steve
> > > > >
> > > > > --- In , "rtstofer" <rstofer@p...>
> wrote:
> > > > > > I finally figured out how to attach a zip file - I have
to
> > send
> > > > it
> > > > > by
> > > > > > email to from my registered mail
> > > > account.
> > > > > I
> > > > > > can't do it from work so I will post it tonight.
> > > > > >
> > > > > > I have a zip file with the .asm, .inc and related project
> > > files -
> > > > > > known to work. Just extract to c:\test\ and open the
> project
> > > in
> > > > > > MPASM IDE.
> > > > > >
> > > > > > I tried to create the failure you are having and can't
seem
> > to
> > > > > > duplicate it. Once we are both working from the same
files
> > > maybe
> > > > > it
> > > > > > will become clear.
> > > > > >
> > > > > >
> > > > > > --- In , "stephendbarnes"
> > > > > > <stephendbarnes@h...> wrote:
> > > > > > > I think I see what is happening but I don't know what
to
> do
> > > > about
> > > > > > it.
> > > > > > > The compiler is actually not looking at my code at all!
> > When
> > > it
> > > > > > gets
> > > > > > > to the "#include macros.inc" it compiles the macros and
> > skips
> > > > the
> > > > > > > rest of my source! If you would like to see the .lst
I'll
> > > post
> > > > it
> > > > > > for
> > > > > > > you to look at. Thanks again for your help.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Steve
> > > > > > >
> > > > > > > --- In , "rtstofer"
<rstofer@p...>
> > > wrote:
> > > > > > > >
> > > > > > > > OOPS! Of course the new label in my prior message
goes
> > > ahead
> > > > of
> > > > > > the
> > > > > > > > MOVF PORTA,W. Comes from typing without thinking.
> > > > > > > >
> > > > > > > > --- In , "stephendbarnes"
> > > > > > > > <stephendbarnes@h...> wrote:
> > > > > > > > > Hello all,
> > > > > > > > > I have been attempting to make use of Karl Lunt's
PIC
> > > > Macros
> > > > > > with
> > > > > > > > no
> > > > > > > > > success
> > > > > > > > > during the build phase. I have followed his
> > instructions
> > > > and
> > > > > > > > emailed
> > > > > > > > > him for
> > > > > > > > > help with no response. I'm using MPLab 6.20 and
> writing
> > > > some
> > > > > > test
> > > > > > > > > code for
> > > > > > > > > the 16F84A. The
> > > > > > > > > following text describes my code and the errors
upon
> > > build.
> > > > > > Could
> > > > > > > > > anyone
> > > > > > > > > take a look and see if you could provide some
> insight?
> > > > Thanks
> > > > > > in
> > > > > > > > > advance for
> > > > > > > > > any help.
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > > Stephen D. Barnes
> > > > > > > > >
> > > > > > > > > My code follows:
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > > ***
> > > > > > > > > ERRORLEVEL -224 ; suppress message
> > > because
> > > > of
> > > > > > tris
> > > > > > > > > ERRORLEVEL -302 ; suppress message
> > > because
> > > > of
> > > > > > > page
> > > > > > > > > change
> > > > > > > > >
> > > > > > > > > list pF84A ; list
> > > directive
> > > > to
> > > > > > > define
> > > > > > > > > processor
> > > > > > > > > #include <p16F84A.inc> ; processor
specific
> > > > > variable
> > > > > > > > > definitions
> > > > > > > > > #include ".\macros.asm"
> > > > > > > > >
> > > > > > > > > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON &
> _XT_OSC
> > > > > > > > >
> > > > > > > > > ; '__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.
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > > > > > > > ;;
> > > > > > > > > ;;;;;;
> > > > > > > > > ;;;;;;;;;;;;;;;;;
> > > > > > > > > ORG 0x000 ; processor reset vector
> > > > > > > > > goto Main ; go to beginning of program
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > > > > > > > ;;
> > > > > > > > > ;;;;;;
> > > > > > > > > ;;;;;;;;;;;;;;;;;
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > > > > > > > ;;
> > > > > > > > > ;;;;;;
> > > > > > > > > ;;;;;;;;;;;;;;;;;
> > > > > > > > > Main:
> > > > > > > > > clrf PORTB ; PORTB all outputs
> > cleared
> > > > > > > > > bsf STATUS,5 ; Switch to Register Bank 1
> for
> > > TRIS
> > > > > > > > > movlw B'11111111' ; all bits high in W
> > > > > > > > > movwf TRISA ; contents of W
copied
> > to
> > > > > TRISA
> > > > > > > > (PORTA
> > > > > > > > > all
> > > > > > > > > inputs)
> > > > > > > > > movlw B'00000000' ; all bits low in W
> > > > > > > > > movwf TRISB ; contents of W
copied
> > to
> > > > > TRISB
> > > > > > > > (PORTB
> > > > > > > > > all
> > > > > > > > > outputs)
> > > > > > > > > movlw 0 ; 0 in W
> > > > > > > > > movwf OPTION_REG ; contents of W copied
to
> > > > > OPTION_REG
> > > > > > > > (Port
> > > > > > > > > B
> > > > > > > > >
> > > > >
> pullups
> > > > > > > > > enabled)
> > > > > > > > > bcf STATUS,5 ; Switch back to Register
> > Bank 0
> > > > > > > > >
> > > > > > > > > movf PORTA ,0 ; move PORTA bit 0 to W
> register
> > > > > > > > >
> > > > > > > > > case 3
> > > > > > > > > call Reverse
> > > > > > > > > endcase
> > > > > > > > >
> > > > > > > > > case 2
> > > > > > > > > call Left
> > > > > > > > > endcase
> > > > > > > > >
> > > > > > > > > case 1
> > > > > > > > > call Right
> > > > > > > > > endcase
> > > > > > > > >
> > > > > > > > > Reverse:
> > > > > > > > > return
> > > > > > > > > Left:
> > > > > > > > > return
> > > > > > > > > Right:
> > > > > > > > > return
> > > > > > > > >
> > > > > > > > > end
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > > ***
> > > > > > > > >
> > > > > > > > > When I build I get the following error:
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > > ****
> > > > > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o"
> > > > > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > > > >
> > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o"
> > > > > > > > > Skipping link step. The project contains no linker
> > > script.
> > > > > > > > > BUILD FAILED
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > > ****
> > > > > > > > >
> > > > > > > > > Soooo... I created a linker script conforming to
> MPASM
> > > spec
> > > > > > which
> > > > > > > > > reads as
> > > > > > > > > follows and is part of the MPLab project:
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > > ****
> > > > > > > > > FILES macros.o test1.o
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > > ****
> > > > > > > > >
> > > > > > > > > Build now reports the following error:
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > > ****
> > > > > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > > > > > "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o"
> > > > > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > > > >
> > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o"
> > > > > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > > > > IDE\MCHIP_Tools\mplink.exe" "test1.lkr"
> > > > > > > > > "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof"
> > > > > > > > > MPLINK 3.30, Linker
> > > > > > > > > Copyright (c) 2003 Microchip Technology Inc.
> > > > > > > > > Error - section '.cinit' can not fit the section.
> > > > > > Section '.cinit'
> > > > > > > > > length=0x00000004
> > > > > > > > > Errors : 1
> > > > > > > > > BUILD FAILED
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > > ****





The code wants to execute the first case argument it sees. I have
followed it in step mode but I don't yet understand what the macro is
doing. I can comment out the first case (case 3) and it executes the
the first case it sees regardless of the W reg value! I'm stumped and
drowning!!

Regards,
Steve

--- In , "stephendbarnes"
<stephendbarnes@h...> wrote:
> I changed it to match your example and I'm ready to start debugging
> again!
> Thanks a million!
>
> Regards,
> Steve
>
> --- In , "rtstofer" <rstofer@p...> wrote:
> >
> > This will be a problem. The code is loading the loop
> variable 'var'
> > into W and then adding 'incf' and leaving the result in 'incf'.
It
> > needs to be stored in 'var' as in my previous post.
> >
> > At some point you may want to correct your version. Maybe write
a
> > small program and test that it works.
> >
> > --- In , "stephendbarnes"
> > <stephendbarnes@h...> wrote:
> > > Mine looks like this:
> > >
> > > nextf...macro...var,incf
> > > _nxtknt.set....._nxtknt-1
> > > ........movf....var,w
> > > ........addwf...incf,f
> > > ........goto...._for#v(_nxtknt)
> > > _next#v(_nxtknt)
> > > ........endm
> > >
> > >
> > >
> > > --- In , "rtstofer" <rstofer@p...> wrote:
> > > >
> > > > Just to check the version of the macros, look at nextf and it
> > > should
> > > > look like this (after I revised it):
> > > >
> > > > nextf...macro..var,incf
> > > > _nxtknt.set...._nxtknt-1
> > > > ........movf...incf,w..; the code was incorrect here
> > > > ........addwf..var,f...; leave the result in var, not incf
> > > > ........goto..._for#v(_nxtknt)
> > > > _next#v(_nxtknt)
> > > > ........endm
> > > >
> > > > --- In , "rtstofer" <rstofer@p...>
wrote:
> > > > >
> > > > > We must have gotten different versions of the macros. Mine
> did
> > > not
> > > > > have an 'end' statement but I was beginning to suspect that
> > yours
> > > > > did. That would be about the only reason for the assembler
> to
> > > stop
> > > > > early.
> > > > >
> > > > > I am not sure why your code would execute any case. In my
> > > version
> > > > of
> > > > > SIM without a stimulus file the value of PORTA is always
0.
> > This
> > > > > should not execute any case and if you have placed a goto
> loop
> > > > > statement following endselect you should not fall into the
> > > reverse
> > > > > subroutine. The label 'loop' should be before the movwf
> PORTA,W
> > > > >
> > > > > An easy way to trace this code is to put a movlw 3 (or
> > something)
> > > > > immediately after the movwf PORTA,W. This will load W with
a
> > > > > matching value for one of the various cases. I would still
> > mask
> > > > off
> > > > > the unused bits and change the select and case statements
as
> > > > > discussed previously.
> > > > >
> > > > > --- In , "stephendbarnes"
> > > > > <stephendbarnes@h...> wrote:
> > > > > > Thank you. I have made a little progress. I found that
the
> > > > compiler
> > > > > > was only compiling the macros.inc file and stopping
there!
> > I'm
> > > > new
> > > > > to
> > > > > > this and your comments about the .lst file made me go
look
> at
> > > it!
> > > > > > WOW. It reported 0 program words used! Looking at the
list
> I
> > > saw
> > > > > that
> > > > > > none of my code was present. The problem seemed to be
that
> > Karl
> > > > > > Lunt's macro file has the compiler directive "end" at the
> > end.
> > > I
> > > > > > assume that this was causing the compiler to stop dead in
> its
> > > > > tracks.
> > > > > > I removed the "end" directive from the macro file and it
> > > compiled
> > > > > and
> > > > > > simulates. I do have a problem with the thing constantly
> > going
> > > to
> > > > > the
> > > > > > first case "case 3" and ignoring the other two regardless
> of
> > > the
> > > > > > value W. I'll be looking forward to seeing your code. I
> will
> > > try
> > > > > > debugging this myself without yelling for help at every
> turn
> > > > (jump
> > > > > in
> > > > > > with both feet and only yell when drowning!). You have
> been,
> > > and
> > > > > are
> > > > > > being, an enormous help. Thanks again.
> > > > > >
> > > > > > Regards,
> > > > > > Steve
> > > > > >
> > > > > > --- In , "rtstofer" <rstofer@p...>
> > wrote:
> > > > > > > I finally figured out how to attach a zip file - I have
> to
> > > send
> > > > > it
> > > > > > by
> > > > > > > email to from my registered
mail
> > > > > account.
> > > > > > I
> > > > > > > can't do it from work so I will post it tonight.
> > > > > > >
> > > > > > > I have a zip file with the .asm, .inc and related
project
> > > > files -
> > > > > > > known to work. Just extract to c:\test\ and open the
> > project
> > > > in
> > > > > > > MPASM IDE.
> > > > > > >
> > > > > > > I tried to create the failure you are having and can't
> seem
> > > to
> > > > > > > duplicate it. Once we are both working from the same
> files
> > > > maybe
> > > > > > it
> > > > > > > will become clear.
> > > > > > >
> > > > > > >
> > > > > > > --- In , "stephendbarnes"
> > > > > > > <stephendbarnes@h...> wrote:
> > > > > > > > I think I see what is happening but I don't know what
> to
> > do
> > > > > about
> > > > > > > it.
> > > > > > > > The compiler is actually not looking at my code at
all!
> > > When
> > > > it
> > > > > > > gets
> > > > > > > > to the "#include macros.inc" it compiles the macros
and
> > > skips
> > > > > the
> > > > > > > > rest of my source! If you would like to see the .lst
> I'll
> > > > post
> > > > > it
> > > > > > > for
> > > > > > > > you to look at. Thanks again for your help.
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > > Steve
> > > > > > > >
> > > > > > > > --- In , "rtstofer"
> <rstofer@p...>
> > > > wrote:
> > > > > > > > >
> > > > > > > > > OOPS! Of course the new label in my prior message
> goes
> > > > ahead
> > > > > of
> > > > > > > the
> > > > > > > > > MOVF PORTA,W. Comes from typing without thinking.
> > > > > > > > >
> > > > > > > > > --- In , "stephendbarnes"
> > > > > > > > > <stephendbarnes@h...> wrote:
> > > > > > > > > > Hello all,
> > > > > > > > > > I have been attempting to make use of Karl Lunt's
> PIC
> > > > > Macros
> > > > > > > with
> > > > > > > > > no
> > > > > > > > > > success
> > > > > > > > > > during the build phase. I have followed his
> > > instructions
> > > > > and
> > > > > > > > > emailed
> > > > > > > > > > him for
> > > > > > > > > > help with no response. I'm using MPLab 6.20 and
> > writing
> > > > > some
> > > > > > > test
> > > > > > > > > > code for
> > > > > > > > > > the 16F84A. The
> > > > > > > > > > following text describes my code and the errors
> upon
> > > > build.
> > > > > > > Could
> > > > > > > > > > anyone
> > > > > > > > > > take a look and see if you could provide some
> > insight?
> > > > > Thanks
> > > > > > > in
> > > > > > > > > > advance for
> > > > > > > > > > any help.
> > > > > > > > > >
> > > > > > > > > > Regards,
> > > > > > > > > > Stephen D. Barnes
> > > > > > > > > >
> > > > > > > > > > My code follows:
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > > > ***
> > > > > > > > > > ERRORLEVEL -224 ; suppress
message
> > > > because
> > > > > of
> > > > > > > tris
> > > > > > > > > > ERRORLEVEL -302 ; suppress
message
> > > > because
> > > > > of
> > > > > > > > page
> > > > > > > > > > change
> > > > > > > > > >
> > > > > > > > > > list pF84A ; list
> > > > directive
> > > > > to
> > > > > > > > define
> > > > > > > > > > processor
> > > > > > > > > > #include <p16F84A.inc> ; processor
> specific
> > > > > > variable
> > > > > > > > > > definitions
> > > > > > > > > > #include ".\macros.asm"
> > > > > > > > > >
> > > > > > > > > > __CONFIG _CP_OFF & _WDT_OFF & _PWRTE_ON &
> > _XT_OSC
> > > > > > > > > >
> > > > > > > > > > ; '__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.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > > > > > > > > ;;
> > > > > > > > > > ;;;;;;
> > > > > > > > > > ;;;;;;;;;;;;;;;;;
> > > > > > > > > > ORG 0x000 ; processor reset vector
> > > > > > > > > > goto Main ; go to beginning of program
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > > > > > > > > ;;
> > > > > > > > > > ;;;;;;
> > > > > > > > > > ;;;;;;;;;;;;;;;;;
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> > > > > > > > > ;;
> > > > > > > > > > ;;;;;;
> > > > > > > > > > ;;;;;;;;;;;;;;;;;
> > > > > > > > > > Main:
> > > > > > > > > > clrf PORTB ; PORTB all outputs
> > > cleared
> > > > > > > > > > bsf STATUS,5 ; Switch to Register Bank
1
> > for
> > > > TRIS
> > > > > > > > > > movlw B'11111111' ; all bits high in
W
> > > > > > > > > > movwf TRISA ; contents of W
> copied
> > > to
> > > > > > TRISA
> > > > > > > > > (PORTA
> > > > > > > > > > all
> > > > > > > > > > inputs)
> > > > > > > > > > movlw B'00000000' ; all bits low in W
> > > > > > > > > > movwf TRISB ; contents of W
> copied
> > > to
> > > > > > TRISB
> > > > > > > > > (PORTB
> > > > > > > > > > all
> > > > > > > > > > outputs)
> > > > > > > > > > movlw 0 ; 0 in W
> > > > > > > > > > movwf OPTION_REG ; contents of W copied
> to
> > > > > > OPTION_REG
> > > > > > > > > (Port
> > > > > > > > > > B
> > > > > > > > > >
> > > > > >
> > pullups
> > > > > > > > > > enabled)
> > > > > > > > > > bcf STATUS,5 ; Switch back to
Register
> > > Bank 0
> > > > > > > > > >
> > > > > > > > > > movf PORTA ,0 ; move PORTA bit 0 to W
> > register
> > > > > > > > > >
> > > > > > > > > > case 3
> > > > > > > > > > call Reverse
> > > > > > > > > > endcase
> > > > > > > > > >
> > > > > > > > > > case 2
> > > > > > > > > > call Left
> > > > > > > > > > endcase
> > > > > > > > > >
> > > > > > > > > > case 1
> > > > > > > > > > call Right
> > > > > > > > > > endcase
> > > > > > > > > >
> > > > > > > > > > Reverse:
> > > > > > > > > > return
> > > > > > > > > > Left:
> > > > > > > > > > return
> > > > > > > > > > Right:
> > > > > > > > > > return
> > > > > > > > > >
> > > > > > > > > > end
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > > > ***
> > > > > > > > > >
> > > > > > > > > > When I build I get the following error:
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > > > ****
> > > > > > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > > > > >
> "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o"
> > > > > > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > > > > >
> > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o"
> > > > > > > > > > Skipping link step. The project contains no
linker
> > > > script.
> > > > > > > > > > BUILD FAILED
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > > > ****
> > > > > > > > > >
> > > > > > > > > > Soooo... I created a linker script conforming to
> > MPASM
> > > > spec
> > > > > > > which
> > > > > > > > > > reads as
> > > > > > > > > > follows and is part of the MPLab project:
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > > > ****
> > > > > > > > > > FILES macros.o test1.o
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > > > ****
> > > > > > > > > >
> > > > > > > > > > Build now reports the following error:
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > > > ****
> > > > > > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > > > > >
> "test1.asm" /l"test1.lst" /e"test1.err" /o"test1.o"
> > > > > > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > > > > > IDE\MCHIP_Tools\mpasmwin.exe" /q /p16F84A
> > > > > > > > >
> > > "MACROS.ASM" /l"MACROS.lst" /e"MACROS.err" /o"MACROS.o"
> > > > > > > > > > Executing: "E:\Program Files\MPLAB
> > > > > > > > > > IDE\MCHIP_Tools\mplink.exe" "test1.lkr"
> > > > > > > > > > "E:\PIC\test1.o" "E:\PIC\MACROS.o" /o"test1.cof"
> > > > > > > > > > MPLINK 3.30, Linker
> > > > > > > > > > Copyright (c) 2003 Microchip Technology Inc.
> > > > > > > > > > Error - section '.cinit' can not fit the section.
> > > > > > > Section '.cinit'
> > > > > > > > > > length=0x00000004
> > > > > > > > > > Errors : 1
> > > > > > > > > > BUILD FAILED
> > > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>
**********************************************************************
> > > > > > > > > > ****






This is what the generated code should loook like - I have removed
the comments. The left column is the program address, the second
column is the instruction code, the third is the line number (and
yours will vary if you have not put a NOLIST before
#include "macros.inc" and a LIST after.

Some of the fixes I mentioned earlier are not included - some are.

At line 28 we grab the port value to W and then XOR it with
B'00000011' (3). If the result is zero (beq) we go to 'cas1' just
before line 32, XOR it again to restore the value and then call
Reverse. After Reverse returns we go to sel1 just after line 40.

If the value was not 3 then we repeat the process at line 34 for a
value of 2. If the XOR results in zero we call Left, etc.

Lastly we try for a value of 1 and if the result of XOR 3 lines past
line 37 is zero we call Right.

Now, we know that the value grabbed from PORTA and stuffed in W is 0,
right? Unless you have somehow gotten a value in PORTA of the
simulator it just has to be. Well, 0 is not going to match 3, 2 or 1
and we are going to fall through to line 40 (endselect) and then goto
loop.

My great attempt to email a zip file hasn't worked yet so I'll post
this instead. Your generated code should look exactly like this -
let me know if there are differences.
0000 00013 ORG 0x000
0000 2801 00014 goto Main
00015
0001 00016 Main:
0001 0186 00017 clrf PORTB
0002 1683 00018 bsf STATUS,5
0003 30FF 00019 movlw B'11111111'
0004 0085 00020 movwf TRISA
0005 3000 00021 movlw B'00000000'
0006 0086 00022 movwf TRISB
0007 3000 00023 movlw 0 ; 0 in W
0008 0081 00024 movwf OPTION_REG
0009 1283 00025 bcf STATUS,5
00026
000A 00027 loop:
000A 0805 00028 movf PORTA ,0
00029
00030 select
00000001 M _seltot set _seltot+1
00000001 M _selknt set _seltot
00031 case 3
00000001 M _castot set _castot+1
00000001 M _casknt set _castot
000B 3A03 M xorlw 3
M beq cas1
000C 1903 M btfsc STATUS,Z
000D 2810 M goto cas1
000E 3A03 M xorlw 3
000F 2813 M goto ecas1
0010 M cas1
0010 3A03 M xorlw 3
0011 2024 00032 call Reverse
00033 endcase
0012 2823 M goto sel1
0013 M ecas1
00000000 M _casknt set _casknt-1
00034 case 2
00000002 M _castot set _castot+1
MPASM 03.20.07 Released TEST.ASM 4-17-
2003 17:45:47 PAGE 2 LOC OBJECT CODE LINE SOURCE TEXT
VALUE

00000002 M _casknt set _castot
0013 3A02 M xorlw 2
M beq cas2
0014 1903 M btfsc STATUS,Z
0015 2818 M goto cas2
0016 3A02 M xorlw 2
0017 281B M goto ecas2
0018 M cas2
0018 3A02 M xorlw 2
0019 2025 00035 call Left
00036 endcase
001A 2823 M goto sel1
001B M ecas2
00000001 M _casknt set _casknt-1
00037 case 1
00000003 M _castot set _castot+1
00000003 M _casknt set _castot
001B 3A01 M xorlw 1
M beq cas3
001C 1903 M btfsc STATUS,Z
001D 2820 M goto cas3
001E 3A01 M xorlw 1
001F 2823 M goto ecas3
0020 M cas3
0020 3A01 M xorlw 1
0021 2026 00038 call Right
00039 endcase
0022 2823 M goto sel1
0023 M ecas3
00000002 M _casknt set _casknt-1
00040 endselect
0023 M sel1
00000000 M _selknt set _selknt-1
0023 280A 00041 goto loop
00042
0024 00043 Reverse:
0024 0008 00044 return
0025 00045 Left:
0025 0008 00046 return
0026 00047 Right:
0026 0008 00048 return
00049
00050 end
--- In , "stephendbarnes"
<stephendbarnes@h...> wrote:
> The code wants to execute the first case argument it sees. I have
> followed it in step mode but I don't yet understand what the macro
is
> doing. I can comment out the first case (case 3) and it executes
the
> the first case it sees regardless of the W reg value! I'm stumped
and
> drowning!!
>
> Regards,
> Steve




Well, the group list software made a mess out of that - I guess you'll
have to straighten it out in a text editor to make sense of it.

Sorry about that!

--- In , "rtstofer" <rstofer@p...> wrote:
>
> This is what the generated code should loook like - I have removed
> the comments. The left column is the program address, the second
> column is the instruction code, the third is the line number (and
> yours will vary if you have not put a NOLIST before
> #include "macros.inc" and a LIST after.
>
> Some of the fixes I mentioned earlier are not included - some are.
>
> At line 28 we grab the port value to W and then XOR it with
> B'00000011' (3). If the result is zero (beq) we go to 'cas1' just
> before line 32, XOR it again to restore the value and then call
> Reverse. After Reverse returns we go to sel1 just after line 40.
>
> If the value was not 3 then we repeat the process at line 34 for a
> value of 2. If the XOR results in zero we call Left, etc.
>
> Lastly we try for a value of 1 and if the result of XOR 3 lines past
> line 37 is zero we call Right.
>
> Now, we know that the value grabbed from PORTA and stuffed in W is 0,
> right? Unless you have somehow gotten a value in PORTA of the
> simulator it just has to be. Well, 0 is not going to match 3, 2 or 1
> and we are going to fall through to line 40 (endselect) and then goto
> loop.
>
> My great attempt to email a zip file hasn't worked yet so I'll post
> this instead. Your generated code should look exactly like this -
> let me know if there are differences. >
> 0000 00013 ORG 0x000
> 0000 2801 00014 goto Main
> 00015
> 0001 00016 Main:
> 0001 0186 00017 clrf PORTB
> 0002 1683 00018 bsf STATUS,5
> 0003 30FF 00019 movlw B'11111111'
> 0004 0085 00020 movwf TRISA
> 0005 3000 00021 movlw B'00000000'
> 0006 0086 00022 movwf TRISB
> 0007 3000 00023 movlw 0 ; 0 in W
> 0008 0081 00024 movwf OPTION_REG
> 0009 1283 00025 bcf STATUS,5
> 00026
> 000A 00027 loop:
> 000A 0805 00028 movf PORTA ,0
> 00029
> 00030 select
> 00000001 M _seltot set _seltot+1
> 00000001 M _selknt set _seltot
> 00031 case 3
> 00000001 M _castot set _castot+1
> 00000001 M _casknt set _castot
> 000B 3A03 M xorlw 3
> M beq cas1
> 000C 1903 M btfsc STATUS,Z
> 000D 2810 M goto cas1
> 000E 3A03 M xorlw 3
> 000F 2813 M goto ecas1
> 0010 M cas1
> 0010 3A03 M xorlw 3
> 0011 2024 00032 call Reverse
> 00033 endcase
> 0012 2823 M goto sel1
> 0013 M ecas1
> 00000000 M _casknt set _casknt-1
> 00034 case 2
> 00000002 M _castot set _castot+1
> MPASM 03.20.07 Released TEST.ASM 4-17-
> 2003 17:45:47 PAGE 2 > LOC OBJECT CODE LINE SOURCE TEXT
> VALUE
>
> 00000002 M _casknt set _castot
> 0013 3A02 M xorlw 2
> M beq cas2
> 0014 1903 M btfsc STATUS,Z
> 0015 2818 M goto cas2
> 0016 3A02 M xorlw 2
> 0017 281B M goto ecas2
> 0018 M cas2
> 0018 3A02 M xorlw 2
> 0019 2025 00035 call Left
> 00036 endcase
> 001A 2823 M goto sel1
> 001B M ecas2
> 00000001 M _casknt set _casknt-1
> 00037 case 1
> 00000003 M _castot set _castot+1
> 00000003 M _casknt set _castot
> 001B 3A01 M xorlw 1
> M beq cas3
> 001C 1903 M btfsc STATUS,Z
> 001D 2820 M goto cas3
> 001E 3A01 M xorlw 1
> 001F 2823 M goto ecas3
> 0020 M cas3
> 0020 3A01 M xorlw 1
> 0021 2026 00038 call Right
> 00039 endcase
> 0022 2823 M goto sel1
> 0023 M ecas3
> 00000002 M _casknt set _casknt-1
> 00040 endselect
> 0023 M sel1
> 00000000 M _selknt set _selknt-1
> 0023 280A 00041 goto loop
> 00042
> 0024 00043 Reverse:
> 0024 0008 00044 return
> 0025 00045 Left:
> 0025 0008 00046 return
> 0026 00047 Right:
> 0026 0008 00048 return
> 00049
> 00050 end
> --- In , "stephendbarnes"
> <stephendbarnes@h...> wrote:
> > The code wants to execute the first case argument it sees. I have
> > followed it in step mode but I don't yet understand what the macro
> is
> > doing. I can comment out the first case (case 3) and it executes
> the
> > the first case it sees regardless of the W reg value! I'm stumped
> and
> > drowning!!
> >
> > Regards,
> > Steve





Just a thought - is the code actually calling your subroutines or
just messing about with the xor beq stuff? There is a bunch of code
being executed in sequence - there is certainly no magic that makes
the select statement jump to the proper case right off the bat.

First the code evaluates whether W is 3, if not it evaluates whether
W is 2, if not it evaluates whether W is 1, if not it loops back and
gets a new value for W and does the process again.

If any test is true, the appropriate subroutine is called and the
code loops back for a new value of W.

And yes, using a computed goto table is probably faster but the table
gets ugly if there are unused values of W: 1, 3, 19, 22, 29, 234 for
example. You would need a table with 235 entries (0..234) most of
which would branch to an error subroutine for invalid values.

Where the values can be limited to something like [0..3] then a
computed goto table can be faster. Just be sure to forcibly limit
them with something like ANDLW B'00000011' after the value is placed
in W.

Something to think about later.
--- In , "stephendbarnes"
<stephendbarnes@h...> wrote:
> The code wants to execute the first case argument it sees. I have
> followed it in step mode but I don't yet understand what the macro
is
> doing. I can comment out the first case (case 3) and it executes
the
> the first case it sees regardless of the W reg value! I'm stumped
and
> drowning!!
>
> Regards,
> Steve




The 2024 Embedded Online Conference