hi,
i'm not very experienced with assembler directives, so i don't know if this
is achievable.
i have an asm program that has many subroutines, each lights a different
letter on a 5x7 LED display. In my main program, i call whatever subroutine
I want, for example, to display "HELLO" :
start
call HHH ; light up H
call Pause;
call EEE; light up E
call Pause;
call LLL; light up L
call Pause;
call LLL; light up L
call Pause;
call OOO; light up O
call Pause;
goto start
i have programmed the whole alphabet and other characters, but they do not
all fit on the PIC.
what i want to do is program only the ones that get called, and have the
assembler ignore the rest.
i have been looking at #DEFINE, IFDEF, and IF statements, but i can't seem
to figure this out.
can somebody point me in the right direction?
i'm using MPLAB.
--
Scott Larson
3201 S. State. St. box 2561
Chicago, Il, 60616
619-400-9775 http://goldscott.com
On October 16, 2005 10:52 pm, scott larson wrote: {Quote hidden}
> hi,
> i'm not very experienced with assembler directives, so i don't know
> if this is achievable.
> i have an asm program that has many subroutines, each lights a
> different letter on a 5x7 LED display. In my main program, i call
> whatever subroutine I want, for example, to display "HELLO" :
> start
> call HHH ; light up H
> call Pause;
> call EEE; light up E
> call Pause;
> call LLL; light up L
> call Pause;
> call LLL; light up L
> call Pause;
> call OOO; light up O
> call Pause;
> goto start
> i have programmed the whole alphabet and other characters, but they
> do not all fit on the PIC.
> what i want to do is program only the ones that get called, and have
> the assembler ignore the rest.
> i have been looking at #DEFINE, IFDEF, and IF statements, but i
> can't seem to figure this out.
> can somebody point me in the right direction?
> i'm using MPLAB.
create a small asm program with this in it:
#define EXAMPLE 1
#ifdef EXAMPLE
#define HI 1
#define LO 0
#else
#define HI 0
#define LO 1
#endif
#ifndef EXAMPLE
#define X 1
#define Y 2
#else
#define X 3
#define Y 4
#endif
in the code section, insert this:
retlw HI
retlw LO
retlw X
retlw Y
you can also insert this in the code section:
#ifdef EXAMPLE
movlw 5
movlw HI
#else
movlw 10
movlw HI+Y
#endif
try the above with and without "#define EXAMPLE"
>hi,
>i'm not very experienced with assembler directives, so i don't know if this
>is achievable.
>i have an asm program that has many subroutines, each lights a different
>letter on a 5x7 LED display. In my main program, i call whatever subroutine
>I want, for example, to display "HELLO" :
> start
>call HHH ; light up H
>call Pause;
>call EEE; light up E
>call Pause;
>call LLL; light up L
>call Pause;
> call LLL; light up L
>call Pause;
>call OOO; light up O
>call Pause;
>goto start
> i have programmed the whole alphabet and other characters, but they do not
>all fit on the PIC.
>what i want to do is program only the ones that get called, and have the
>assembler ignore the rest.
> i have been looking at #DEFINE, IFDEF, and IF statements, but i can't seem
>to figure this out.
> can somebody point me in the right direction?
> i'm using MPLAB.
>
>--
>Scott Larson
>3201 S. State. St. box 2561
>Chicago, Il, 60616
>619-400-9775
>http://goldscott.com
>
>
--
*
| __O Thomas C. Sefranek spam_OUTWA1RHPTakeThisOuTARRL.net
|_-\<,_ Amateur Radio Operator: WA1RHP
(*)/ (*) Bicycle mobile on 145.41, 448.625 MHz
scott larson wrote:
> i have an asm program that has many subroutines, each lights a different
> letter on a 5x7 LED display. In my main program, i call whatever
> subroutine I want, for example, to display "HELLO" :
> start
> call HHH ; light up H
> call Pause;
> call EEE; light up E
> call Pause;
> call LLL; light up L
> call Pause;
> call LLL; light up L
> call Pause;
> call OOO; light up O
> call Pause;
> goto start
What assembler are you using? MPASM would have barfed on this code because
of opcode mnemonics in column 1. You're going to get a lot more answers
here if you stick to the standard tools. At the very least you should point
out that you're using a non-standard tool. My answers below related to
MPASM.
> i have programmed the whole alphabet and other characters, but they do
> not all fit on the PIC.
Not surprising doing it this way. I would make a single subroutine that you
pass the character to. This does a table lookup and then displays the
result. If you stick to printable ASCII characters, then you only need
codes from 32 to 127 at most. That table and the code to use it only exist
once. You could even write a subroutine that takes a pointer to a string in
program memory and displays that. This would be layered on the previous
subroutine that displays one character.
> what i want to do is program only the ones that get called, and have the
> assembler ignore the rest.
It would be a bit tricky to do this with the assembler. You could do it for
references from one module only. The best way is to put each subroutine in
its own module, make a library of them all, then let the linker pick what it
needs. I do this routinely with all my code except the startup module that
contains the reset vector. That way I can write debug routines that can
stay as part of the project but don't end up in the PIC unless they are
called.
*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com
Tom Sefranek wrote:
> Which PIC are you not able in include the whole alphabet?
> I've never run out of code space... ever!
But Tom, didn't you start with the 18C252 (before it was ready) and then
move up from there? There's a whole world of "little" PICs out there.
You're doing very low volume high cost stuff, but when it's the other way
around the cost of a PIC matters. Most of my PIC projects are either
pushing cycles, RAM, or code space, although usually not all those together.
I do have this one 16F630 project where everything is tight, but this is a
high volume product and the customer absolutely doesn't want a more
expensive PIC in there. The feature set is basically defined by what I can
cram into the PIC. Personally I think this is the fun part. It's not so
hard to design something when plenty of resources are available. The real
challenge is optimising capability together with cost. That's why I
sometimes say our motto is "20 pounds of firmware in a 10 pound PIC".
*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com
On 17 Oct 2005, at 12:43, Olin Lathrop wrote:
> I do have this one 16F630 project where everything is tight, but
> this is a
> high volume product and the customer absolutely doesn't want a more
> expensive PIC in there. The feature set is basically defined by
> what I can
> cram into the PIC. Personally I think this is the fun part. It's
> not so
> hard to design something when plenty of resources are available.
> The real
> challenge is optimising capability together with cost. That's why I
> sometimes say our motto is "20 pounds of firmware in a 10 pound PIC".
"An engineer is someone who can do for $1 what any fool can do for $10"
2005/10/17, Tom Sefranek <.....tcsKILLspam@spam@cmcorp.com>:
> Which PIC are you not able in include the whole alphabet?
> I've never run out of code space... ever!
Just to explain this: supposing an alphabet of 40 characters, a
reasonable estimate for a 5*7 display would be 40*5=200 program memory
words. Usually those are available (I ran out of program memory
several times already, so I wouldn't say "ever") and if not, there are
some clever compressions you can do to reduce it further (let me know
if you need those).
If you code each letter as an actual subroutine, you would consume a
lot more space. A better design would be to use a table (Microchip
AN556, I believe) and retrieve the five bytes needed for a character
and output them accordingly. An example routine of the concept, which
will probably not compile (I just wrote it in this Email):
; This function assumes the character to be in "Character5x7"
; and the desired line to be in "Line5x7"
Get5x7VerticalLine
banksel Character5x7 ; Make sure we talk about the right variable
clrf STATUS,C ; Start multiplication by five
rlf Character5x7,w ; Multiply by two
movwf GVLine ; Store
clrf STATUS,C ; Continue multiplication by five
rlf GVLine,f ; Multiply by four
movf Character5x7,w ; Continue multiplication by five
addwf GVLine,f ; *2*2+1=5
movf Line5x7,f ; Add the desired line
addwf GVLine,w ; W now contains location in memory
pagesel CharacterTable ; Point to the character table
movwf PCL ; Jump into the table
; This is the character table. Make sure that it starts on a 256 aligned
; boundary in memory.
CharacterTable
dt 127,9,9,9,127 ; A
dt 127,73,73,79,120 ; B
...
Note that I used "pagesel" here to select the upper bits of PCLATH
used for table jumps, I'm not sure if pagesel actually does this. If
not, you would have to manually set these bits.
A similar construction could be used to send the actual message,
saving space there too.
Close, it was the PIC18C452.
I have NEVER been even close to out of code space.
It takes a HLL Compiler to do that.
Now RAM and cycles on the other hand...
> Tom Sefranek wrote:
>
>> Which PIC are you not able in include the whole alphabet?
>> I've never run out of code space... ever!
>
>
> But Tom, didn't you start with the 18C252 (before it was ready) and then
> move up from there? There's a whole world of "little" PICs out there.
> You're doing very low volume high cost stuff, but when it's the other way
> around the cost of a PIC matters. Most of my PIC projects are either
> pushing cycles, RAM, or code space, although usually not all those
> together.
>
> I do have this one 16F630 project where everything is tight, but this
> is a
> high volume product and the customer absolutely doesn't want a more
> expensive PIC in there. The feature set is basically defined by what
> I can
> cram into the PIC. Personally I think this is the fun part. It's not so
> hard to design something when plenty of resources are available. The
> real
> challenge is optimising capability together with cost. That's why I
> sometimes say our motto is "20 pounds of firmware in a 10 pound PIC".
>
>
> *****************************************************************
> Embed Inc, embedded system specialists in Littleton Massachusetts
> (978) 742-9014, http://www.embedinc.com
--
*
| __O Thomas C. Sefranek WA1RHPKILLspamARRL.net
|_-\<,_ Amateur Radio Operator: WA1RHP
(*)/ (*) Bicycle mobile on 145.41, 448.625 MHz
>
> Which PIC are you not able in include the whole alphabet?
> I've never run out of code space... ever!
>
> scott larson wrote:
>
> >hi,
> >i'm not very experienced with assembler directives, so i don't know if
> this
> >is achievable.
> >i have an asm program that has many subroutines, each lights a different
> >letter on a 5x7 LED display. In my main program, i call whatever
> subroutine
> >I want, for example, to display "HELLO" :
> > start
> >call HHH ; light up H
> >call Pause;
> >call EEE; light up E
> >call Pause;
> >call LLL; light up L
> >call Pause;
> > call LLL; light up L
> >call Pause;
> >call OOO; light up O
> >call Pause;
> >goto start
> > i have programmed the whole alphabet and other characters, but they do
> not
> >all fit on the PIC.
> >what i want to do is program only the ones that get called, and have the
> >assembler ignore the rest.
> > i have been looking at #DEFINE, IFDEF, and IF statements, but i can't
> seem
> >to figure this out.
> > can somebody point me in the right direction?
> > i'm using MPLAB.
> >
> >--
> >Scott Larson
> >3201 S. State. St. box 2561
> >Chicago, Il, 60616
> >619-400-9775
> >http://goldscott.com
> >
> >
>
> --
> *
> | __O Thomas C. Sefranek EraseMEWA1RHPspam_OUTTakeThisOuTARRL.net
> |_-\<,_ Amateur Radio Operator: WA1RHP
> (*)/ (*) Bicycle mobile on 145.41, 448.625 MHz
>
> hamradio.cmcorp.com/inventory/Inventory.html
> http://www.harvardrepeater.org
>
>
Then perhaps you choose the wrong PIC in the first place.
Or maybe PICs are not the best choice for your applications. ;-)
Regards,
Xiaofan
-----Original Message-----
From: James Humes
Sent: Tuesday, October 18, 2005 7:53 AM
To: Microcontroller discussion list - Public.
Subject: Re: [PIC] assembler directive question
I run out of code space all the time!
On 10/17/05, Tom Sefranek <tcsspam_OUTcmcorp.com> wrote:
>
> Which PIC are you not able in include the whole alphabet?
> I've never run out of code space... ever!
>
Can you show us one or two of your subroutines? It sounds like you
might have a lot of redundant code. I wonder why you don't have a
single subroutine, the character bit map info might be drawn from a table.
A possible way to include only wanted routines is to disable ALL of
them with "remark" prefixes and then let them in one by one till you
don't get a compilation error.
>> scott larson wrote:
>>
>> >hi,
>> >i'm not very experienced with assembler directives, so i don't know if
>> this
>> >is achievable.
>> >i have an asm program that has many subroutines, each lights a different
>> >letter on a 5x7 LED display. In my main program, i call whatever
>> subroutine
>> >I want, for example, to display "HELLO" :
>> > start
>> >call HHH ; light up H
>> >call Pause;
>> >call EEE; light up E
>> >call Pause;
>> >call LLL; light up L
>> >call Pause;
>> > call LLL; light up L
>> >call Pause;
>> >call OOO; light up O
>> >call Pause;
>> >goto start
>> > i have programmed the whole alphabet and other characters, but they do
>> not
>> >all fit on the PIC.
>> >what i want to do is program only the ones that get called, and have the
>> >assembler ignore the rest.
>> > i have been looking at #DEFINE, IFDEF, and IF statements, but i can't
>> seem
>> >to figure this out.
>> > can somebody point me in the right direction?
>> > i'm using MPLAB.
my code is very redundant. i have not learned about tables yet, but clearly
that is the next step i must take. maarten, bill, and olin have made me
realize what i need to do.
each letter looks some thing like this:
;**** AAA Light up letter A
;
; O
; O O
; O O
; O O
; OOOOO
; O O
; O O
AAA
;****Set up CYCLE counter
movlw CYCLES ;change this value to change the length of time the letter is
displayed, about 0x80
movwf CYCLE ;register to move CYCLES into
AAA1
;Column 1
movlw b'11101111' ;low column 1 (for common cathode display)
movwf PORTA
movlw b'00011111' ; first part of letter
movwf PORTB
call Delay ; Short delay (count down from 0xFF)
;Column 2
movlw b'10111'
movwf PORTA ; rotate PORTA to next column 10111 (for some reason rotate
wasn't working, so reverted back to movlw, any advice?)
movlw b'00100100' ;
movwf PORTB
call Delay
;Column 3
movlw b'11011' ; rotate PORTA to next column 11011
movwf PORTA
movlw b'01000100' ;
movwf PORTB
call Delay
;Column 4
movlw b'11101'
movwf PORTA ; rotate PORTA to next column 11101
movlw b'00100100' ;
movwf PORTB
call Delay
;Column 5
movlw b'11110'
movwf PORTA ; rotate PORTA to next column 11110
movlw b'00011111' ;
movwf PORTB
call Delay
;turn off last column
movlw 0h
movwf PORTB
;Cycle through the letter
decfsz CYCLE,1
goto AAA1
return
>
> Scott,
>
> Can you show us one or two of your subroutines? It sounds like you
> might have a lot of redundant code. I wonder why you don't have a
> single subroutine, the character bit map info might be drawn from a table.
>
> A possible way to include only wanted routines is to disable ALL of
> them with "remark" prefixes and then let them in one by one till you
> don't get a compilation error.
>
>
> >> scott larson wrote:
> >>
> >> >hi,
> >> >i'm not very experienced with assembler directives, so i don't know if
> >> this
> >> >is achievable.
> >> >i have an asm program that has many subroutines, each lights a
> different
> >> >letter on a 5x7 LED display. In my main program, i call whatever
> >> subroutine
> >> >I want, for example, to display "HELLO" :
> >> > start
> >> >call HHH ; light up H
> >> >call Pause;
> >> >call EEE; light up E
> >> >call Pause;
> >> >call LLL; light up L
> >> >call Pause;
> >> > call LLL; light up L
> >> >call Pause;
> >> >call OOO; light up O
> >> >call Pause;
> >> >goto start
> >> > i have programmed the whole alphabet and other characters, but they
> do
> >> not
> >> >all fit on the PIC.
> >> >what i want to do is program only the ones that get called, and have
> the
> >> >assembler ignore the rest.
> >> > i have been looking at #DEFINE, IFDEF, and IF statements, but i can't
> >> seem
> >> >to figure this out.
> >> > can somebody point me in the right direction?
> >> > i'm using MPLAB.
scott larson wrote:
> AAA
> ;****Set up CYCLE counter
> movlw CYCLES ;change this value to change the length of time the letter
> is displayed, about 0x80
> movwf CYCLE ;register to move CYCLES into
> AAA1
> ;Column 1
> movlw b'11101111' ;low column 1 (for common cathode display)
> movwf PORTA
> movlw b'00011111' ; first part of letter
> movwf PORTB
> ...
This is now the second time you posted code that could not possibly have
assembled with MPASM. If you want further help, you need to read and
respond to my previous post.
*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com
the code does assemble in MPLAB. when i copy and paste, my browser takes out
the space in the first column. when i view my previous post in a fixed-width
font, there is a space in the first column.
>
> scott larson wrote:
> > AAA
> > ;****Set up CYCLE counter
> > movlw CYCLES ;change this value to change the length of time the letter
> > is displayed, about 0x80
> > movwf CYCLE ;register to move CYCLES into
> > AAA1
> > ;Column 1
> > movlw b'11101111' ;low column 1 (for common cathode display)
> > movwf PORTA
> > movlw b'00011111' ; first part of letter
> > movwf PORTB
> > ...
>
> This is now the second time you posted code that could not possibly have
> assembled with MPASM. If you want further help, you need to read and
> respond to my previous post.
>
>
> *****************************************************************
> Embed Inc, embedded system specialists in Littleton Massachusetts
> (978) 742-9014, http://www.embedinc.com
scott larson wrote:
> the code does assemble in MPLAB. when i copy and paste, my browser
> takes out the space in the first column. when i view my previous post
> in a fixed-width font, there is a space in the first column.
I'm viewing it in a fixed pitch font too, but I see no space. Neatness and
clarity count. Make sure there are a few hard spaces before mnemonics
before posting code here.
*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com
On Mon, 2005-10-17 at 18:35 -0400, Tom Sefranek wrote:
> Close, it was the PIC18C452.
> I have NEVER been even close to out of code space.
Then you haven't done very much.
> It takes a HLL Compiler to do that.
What?? No, not at all. I've run out of code space multiple times,
without an HLL.
> Now RAM and cycles on the other hand...
Well there you go. More often then not when approaching a problem a
designer has choices as to what resources are more important.
There are many cases where code space can be sacrificed to end up with
more cycles and ram to play with. A good example of this is dealing with
complex equations. While simply putting the equation into the PIC works,
and doesn't use much code (since most of the math code would already be
there for other purposes), it often ends up using a TON of cycles and
quite a few ram locations.
OTOH if you use a lookup table (with perhaps some small interpolation)
you give up a lot of code space to free up a ton of cycles and ram.
If you regularly run out of ram and cycles, and yet never run out of
code space it SOUNDS like you aren't balancing things in such a way to
make as much use of your hardware as possible.
There's nothing wrong with this, it'll just mean you need a more
powerful PIC to do the job then is technically required.
In a hobbyist type environment this is fine, since an extra $2 for a
more powerful PIC doesn't matter. In a professional environment this
isn't that good, since your product will be more expensive then it needs
to be.
Sorry for being a little harsh, but saying an HLL is needed to run out
of code space is simply incorrect.
Herbert Graf wrote:
> If you regularly run out of ram and cycles, and yet never run out of
> code space it SOUNDS like you aren't balancing things in such a way to
> make as much use of your hardware as possible.
Or you needed that particular PIC because of its peripherals, pins, and/or
processing power and the large code space just tagged along.
> There's nothing wrong with this, it'll just mean you need a more
> powerful PIC to do the job then is technically required.
>
> In a hobbyist type environment this is fine, since an extra $2 for a
> more powerful PIC doesn't matter. In a professional environment this
> isn't that good, since your product will be more expensive then it needs
> to be.
First, the distinction isn't between hobby and professional projects, but
between low and high volumes. Hobby projects are just assumed to be low
volume.
Second, if you're making 5-10 units a year and each cost several 100K$, then
the cost of the PIC is swamped by the cost of the development effort. In
that case you want to chose the PIC that will require the least worrying
about resources. An extra $2 times 20 PICs is worth it if you can save half
an your by not having to worry about program memory usage.
> Sorry for being a little harsh,
Yes it is, especially when there is a legitimate reason to chose the biggest
bestest and be done with it, and since Tom happens to be in that situation.
> but saying an HLL is needed to run out
> of code space is simply incorrect.
No, but it helps.
*****************************************************************
Embed Inc, embedded system specialists in Littleton Massachusetts
(978) 742-9014, http://www.embedinc.com
>On Mon, 2005-10-17 at 18:35 -0400, Tom Sefranek wrote:
>
>
>>Close, it was the PIC18C452.
>>I have NEVER been even close to out of code space.
>>
>>
>
>Then you haven't done very much.
>
>
(Giggle) Nah!
I guess I havn't done much...
The NeuroFocus Brain Scanner with 28 18C452s,
The MollyQ small animal machine with 48 18F4520s,
The Fetal Oxy machine with 20 or so PICs,
The Analysis Tower project with 5 or so PICs
The Tech Marine controllers, (Olin's old project)
and a BUNCH of odds and ends controllers supporting the research we do,
Lots of Ham radio related stuff,
Lots of solar projects,
Heck, I even did some part of a project for Olin...
Your right, I haven't done much.
--
*
| __O Thomas C. Sefranek spamBeGoneWA1RHPspamBeGoneARRL.net
|_-\<,_ Amateur Radio Operator: WA1RHP
(*)/ (*) Bicycle mobile on 145.41, 448.625 MHz
>>> Close, it was the PIC18C452.
>>> I have NEVER been even close to out of code space.
>
> (Giggle) Nah!
> I guess I havn't done much...
> The NeuroFocus Brain Scanner with 28 18C452s,
> The MollyQ small animal machine with 48 18F4520s,
> The Fetal Oxy machine with 20 or so PICs,
>
Oh, you use MULTIPLE PICs. Obviously, that's CHEATING!