Searching \ for 'MPASM macro' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/language/index.htm?key=asm
Search entire site for: 'MPASM macro'.

Truncated match.
PICList Thread
'MPASM macro'
1997\04\09@023657 by Ruben Jnsson

flavicon
face
Hi

When I write a program for the PIC (or any other destination)
I define 2 symbols and 1 definition for bit variables:

 b_redled  equ 3        ;It's bit position in the file reg.
 m_redled equ 1 << b_redled       ;It's mask value.
 #define f_redled  port_a.,b_redled     ;It's flag definition

This way I can do the following:
  bsf  f_redled     ;Direct bit access with flagdefinition

  movlw (m_redled | ....)   ;Byte manipulation with mask symbol
  tris port_a

  btfss temp,b_redled  ;Bit access on a copy of the original file
register.

Instead of the 3 definitions above I would like to do it
with one macro, something like:
 bitdef    redled,3,port_a

I havn't found a way to do this with mpasm's macro
functions. The problem here is that I can't create new
symbolnames based on a macro argument with a
prefix added to it (b_, m_ and f_).

Is there any way of doing this with mpasm ?

(Of course I could do a preprocessor program that
substituted the bitdef... with the 3 definitions above.
This would, however, change the number of lines
in the assembled source which in turn would mess
up the line numbers from mpasm's error file.)


------------------------------------
Ruben Joensson
AB Liros Elektronik
Box 9124
200 39 Malmoe
Sweden
Tel +46 40 14 20 80
Mail: spam_OUTrubenTakeThisOuTspamsbbs.se
------------------------------------

1997\04\09@093527 by myke predko

flavicon
face
Ruben Joensson wrote:
<SNIP>
>Instead of the 3 definitions above I would like to do it
>with one macro, something like:
>  bitdef    redled,3,port_a
>
>I havn't found a way to do this with mpasm's macro
>functions. The problem here is that I can't create new
>symbolnames based on a macro argument with a
>prefix added to it (b_, m_ and f_).
>
>Is there any way of doing this with mpasm ?

No.

>(Of course I could do a preprocessor program that
>substituted the bitdef... with the 3 definitions above.
>This would, however, change the number of lines
>in the assembled source which in turn would mess
>up the line numbers from mpasm's error file.)

I wish there was.  I *once* worked with a language that had a macro
processor that could do this - it really was as powerful as the language it
was coupled with.

It made stuff like you're proposing great to create and really easy.


Unfortunately, such power is occasionally used for evil - I was responsible
for maintaining an RTOS that was written *completely* with these types of
macro functions (absolutely *no* code in the source)  The first time I had
to fix something, I had to go through each macro source file and turn on the
listing function.  It was hell.

The original authors were all PhDs, which should explain why it was done
this way.


If you do come up with a preprocessor that has this type of function, I
would be interested in seeing it.  I think there are a lot of advantages to
macro system like you are proposing.

Good Luck!

myke

"Some people say that foreign cars handle best, while others say domestic.
For my money, nothing handles as well as a rental car." - P.J. O'Rourke


'MPASM MACRO'
1998\04\06@194553 by Leonardo De Palo
flavicon
face
Ciao at all of you,

I'm 3 week old novice of PIC and have became an entusiastic of 16C84.
As a case study I have decided to buid a RPM bar LED indicator for the
motorcycle (like copy in progress indicator).
Up to now I have encountered the tipical problems of the new processor that
can be solved trying and testing, but now I have a sensation of frustration
and impotence.
Now I'm in trouble because I need to compose a routine like "case"  or the
tipical;

"  IF   TMR0  >= 196 GOTO AnyLabel  ELSE GOTO OtherLabel".

From my local MICROCHIP distributor I have obtained the last CD ROM "1997
TECHNICAL LIBRARY SECOND EDITION", and I have printed out the 156 pages of
"MPASM USER'S GUIDE" and under chapter 6, on page 75 I have found all
instruction that seems very useful for me. (multiply, divide, less than,
etc), but no words about the use of it. (Probably my bad english contribute
in missing understanding).

Looking on all routine that i have the opportunity to see, no macro one use
of this operators. Why?

I would like understand how build a macro using the aritmetic operators. I
think this list shoul be the better place to discuss about this argument.

Can someone illuminate my darkness.

Thank in advance at all of you

Saluti

.....leo.depaloKILLspamspam@spam@telesys.it

1998\04\06@203922 by Andrew Warren

face
flavicon
face
Leonardo De Palo <PICLISTspamKILLspamMITVMA.MIT.EDU> wrote:

> I need to compose a routine like "case"  or the tipical;
>
>  "  IF   TMR0  >= 196 GOTO AnyLabel  ELSE GOTO OtherLabel".

Leonardo:

   MOVLW   196
   SUBWF   TMR0,W
   BC      AnyLabel
   GOTO    OtherLabel

-Andy

=== Andrew Warren - .....fastfwdKILLspamspam.....ix.netcom.com
=== Fast Forward Engineering - Vista, California
=== http://www.geocities.com/SiliconValley/2499

1998\04\06@204124 by Regulus Berdin

flavicon
face
>  "  IF   TMR0  >= 196 GOTO AnyLabel  ELSE GOTO OtherLabel".

       MOVLW   196
       SUBWF   TMR0,W
       BTFSC   STATUS,0
       GOTO    ANYLABEL
       GOTO    OTHERLABEL

Reggie

1998\04\11@201508 by Regulus Berdin

flavicon
face
Hi Leonardo

>Question one:
>
>For easily the example I have change the TMR0 in  Count
>I do not  have fully understand the meaning of the instructions
>
>SUBWF   COUNT,W
>BTFSC   STATUS,0
>
>first assumption:
>assuming that the current value of Count is 200
>subtract from Count  the value of 196
>The result is 4 and is stored back to Count
>the carry should be on  (is correct?)

Yes CARRY is on.
It is only CLEARED when there is a BORROW.
The result 4 is stored in W,not in COUNT.

To store in COUNT if the command is:
SUBWF    COUNT,F    ;note the F at the end, meaning result is
                                 ;stored in the File register or COUNT.

>Second assumption:
>assuming that the current value of Count is 196
>subtract from Count  the value of 196
>The result is 0 and is stored back to Count
>the carry should be on (is correct?)
As before, result is stored in W and CARRY on.

>Third assumption:
>assuming that the current value of Count is 190
>subtract from Count  the value of 196
>The result is 249 (is correct?) and is stored back to Count
>the carry should be off (is correct?)

The result is 250 or 0xFA and stored in W not if COUNT.
CARRY is OFF (correct).

Subtraction works like this:
190 - 196 = 190 + 2'scomplement (196)
190 + 60  = 250        ; Note no overflow/carry

2's complement is done by negating and then add 1.
196  = 0xC4 = 0b11000100
negating: 0b11000100 -> 0b00111011 = 0x3B = 59
add 1    : 59 + 1 = 60

>Looking at the manual  DS30430B on page 15 fig. 4-5, bit 0 is set ADDWF and
>ADDLW and for me is not clear (probably for my bad english).
>Could you please explain.
Sorry I don't have the manual at this moment, but what register for bit 0
are you refering?

{Quote hidden}

I'll try (untested):
COUNT < 240,    RB1
COUNT <144,    RB1,RB2
   .
   .
   .
COUNT <20,    ....

-----
START:
       CLRF    LIGHTS1
       CLRF    LIGHTS2

       MOVLW    240
       SUBWF    COUNT,W
       BTFSC      STATUS,0
         GOTO     LAST
       BSF          STATUS,0
       RLC          LIGHTS1

       MOVLW    144
       SUBWF    COUNT,W
       BTFSC      STATUS,0
         GOTO     LAST
       BSF          STATUS,0
       RLC          LIGHTS1

       MOVLW    105
       SUBWF    COUNT,W
       BTFSC      STATUS,0
         GOTO     LAST
       BSF          STATUS,0
       RLC          LIGHTS1

           .
           .
           .

       MOVLW    36
       SUBWF    COUNT,W
       BTFSC      STATUS,0
         GOTO     LAST
       BSF          STATUS,0
       RLC          LIGHTS1

       MOVLW    28
       SUBWF    COUNT,W
       BTFSC      STATUS,0
         GOTO     LAST
       BSF          STATUS,0
       RLC          LIGHTS1
       RLC          LIGHTS2

       MOVLW    20
       SUBWF    COUNT,W
       BTFSC      STATUS,0
         GOTO     LAST
       BSF          STATUS,0
       RLC          LIGHTS1
       RLC          LIGHTS2

LAST:
       RLC           LIGHTS1
       RLC           LIGHTS2

       MOVF        LIGHTS1,W
       MOVWF     PORTB
       MOVF        LIGHTS2,W
       MOVWF     PORTA


Reggie

More... (looser matching)
- Last day of these posts
- In 1998 , 1999 only
- Today
- New search...