Searching \ for '[PIC]: How to do token pasting in MPASM?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/languages.htm?key=asm
Search entire site for: 'How to do token pasting in MPASM?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: How to do token pasting in MPASM?'
2003\02\20@153322 by Ned Konz

flavicon
face
[Sorry for those of you who get this twice; I wasn't sure whether the
subject flag rules have been changed to fix the broken mail clients
yet or not.]

Say I want to make a MPASM macro that will be invoked as:

       MyMacro abc,xyz

and will generate the following code:

abcxyz    equ 123

That is, it pastes its two arguments together to make a label. Is this
possible in MPASM? How about:

abcxyz    equ "abcxyz"

Which also pastes the arguments together and makes a string out of
them.

I know how to do it in C using the ## token pasting operator and the #
stringizing operators (and the fact that two adjacent strings are
merged).

But I only see the #v(<expr>) form that would allow tokens to be
pasted together (with an intervening number).

After reading the MPASM manual I can't figure out how to do these. I
hope this isn't an oversight.

Thanks,
--
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE

--
http://www.piclist.com hint: To leave the PICList
spam_OUTpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu>

2003\02\20@221505 by Dwayne Reid

flavicon
face
At 12:30 PM 2/20/03 -0800, Ned Konz wrote:

>Say I want to make a MPASM macro that will be invoked as:
>
>         MyMacro abc,xyz
>
>and will generate the following code:
>
>abcxyz    equ 123
>
>That is, it pastes its two arguments together to make a label. Is this
>possible in MPASM? How about:

This may not help, but will #define work for you?  I recall that I tried in
vain to make a macro do something out of the ordinary but was able to get
#define to do what I wanted.  Don't recall what it was, though.

dwayne

--
Dwayne Reid   <.....dwaynerKILLspamspam@spam@planet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 19 years of Engineering Innovation (1984 - 2003)
 .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-
    `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamKILLspammitvma.mit.edu>

2003\02\20@222533 by Ned Konz

flavicon
face
On Thursday 20 February 2003 07:12 pm, Dwayne Reid wrote:
> At 12:30 PM 2/20/03 -0800, Ned Konz wrote:
> >Say I want to make a MPASM macro that will be invoked as:
> >
> >         MyMacro abc,xyz
> >
> >and will generate the following code:
> >
> >abcxyz    equ 123
> >
> >That is, it pastes its two arguments together to make a label. Is
> > this possible in MPASM? How about:
>
> This may not help, but will #define work for you?  I recall that I
> tried in vain to make a macro do something out of the ordinary but
> was able to get #define to do what I wanted.  Don't recall what it
> was, though.

No, I couldn't find a way to make #define work.

--
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam.....mitvma.mit.edu>

2003\02\20@233452 by Dwayne Reid

flavicon
face
At 07:23 PM 2/20/03 -0800, Ned Konz wrote:
>On Thursday 20 February 2003 07:12 pm, Dwayne Reid wrote:
>
>No, I couldn't find a way to make #define work.

Can you give a concrete example of what you want to accomplish?  In other
words, show the specific input and output you want (as opposed to the
generic xyz examples you posted earlier).  I'm thinking that once we see
what you are trying to accomplish, someone might have an idea.

dwayne

--
Dwayne Reid   <EraseMEdwaynerspam_OUTspamTakeThisOuTplanet.eon.net>
Trinity Electronics Systems Ltd    Edmonton, AB, CANADA
(780) 489-3199 voice          (780) 487-6397 fax

Celebrating 19 years of Engineering Innovation (1984 - 2003)
 .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-.   .-
    `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'   `-'
Do NOT send unsolicited commercial email to this email address.
This message neither grants consent to receive unsolicited
commercial email nor is intended to solicit commercial email.

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamspam_OUTmitvma.mit.edu>

2003\02\21@005316 by Ned Konz

flavicon
face
On Thursday 20 February 2003 08:32 pm, Dwayne Reid wrote:
> At 07:23 PM 2/20/03 -0800, Ned Konz wrote:
> >On Thursday 20 February 2003 07:12 pm, Dwayne Reid wrote:
> >
> >No, I couldn't find a way to make #define work.
>
> Can you give a concrete example of what you want to accomplish?  In
> other words, show the specific input and output you want (as
> opposed to the generic xyz examples you posted earlier).  I'm
> thinking that once we see what you are trying to accomplish,
> someone might have an idea.

What I want to do is to make a set of macros for programming
state-machine based programs.

Each type of state machine (there can be multiple instances of the
same kind of state machine, of course) has several tables associated
with it, as well as one subroutine per state.

I want to make it so you can have two different kinds of state
machines that have states with the same name (to make it easier to
re-use state machine code).

So I want to decorate the enames of the state subroutines with the
name of the kind of state machine they're used in. This way, I can
have two "idle" states in different kinds of state machines, but
their labels will still be unique.

I should be able to do this using the #v() operator to paste tokens,
though they'll have a useless number in between. At least they'll be
unique.

--
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\21@050817 by Wouter van Ooijen

face picon face
> This may not help, but will #define work for you?  I recall
> that I tried in
> vain to make a macro do something out of the ordinary but was
> able to get
> #define to do what I wanted.  Don't recall what it was, though.

IFAIK it won't help in this case, but you can combine #define and normal
macro's to re-define PIC instrcutions, for instance to let 'nop' be
interpreted as 'halt', but only on odd addresses. Now how does that
compare to re-difining 0?

Wouter van Ooijen

-- -------------------------------------------
Van Ooijen Technische Informatica: http://www.voti.nl
consultancy, development, PICmicro products

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\21@074558 by Sergio Masci

picon face
----- Original Message -----
From: Ned Konz <@spam@nedKILLspamspamBIKE-NOMAD.COM>
To: <KILLspamPICLISTKILLspamspamMITVMA.MIT.EDU>
Sent: Thursday, February 20, 2003 8:30 PM
Subject: [PIC]: How to do token pasting in MPASM?


{Quote hidden}

Perhaps you could use the m4 macro processor as a preprocessor or the GNU C
preprocessor. You might even consider a better assembler that does what you
want out of the box. Maybe something that lets you assign strings to
assembler variables and manipulate them during the course of the assembly
like you would in a high level language.

Regards
Sergio Masci

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\21@122842 by Ned Konz

flavicon
face
On Friday 21 February 2003 04:51 am, Sergio Masci wrote:
> Perhaps you could use the m4 macro processor as a preprocessor or
> the GNU C preprocessor. You might even consider a better assembler
> that does what you want out of the box. Maybe something that lets
> you assign strings to assembler variables and manipulate them
> during the course of the assembly like you would in a high level
> language.

You mean I can't assign strings to assembler variables? Ugh...

I did consider using m4, but for what I need it's just as easy to have
another program spit out simple MPASM syntax.

As it is, I'm making a graphical state machine tool using Squeak that
will spit out PIC code; I just need something right now.

--
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\21@131352 by Sergio Masci

picon face
----- Original Message -----
From: Ned Konz <RemoveMEnedTakeThisOuTspamBIKE-NOMAD.COM>
To: <spamBeGonePICLISTspamBeGonespamMITVMA.MIT.EDU>
Sent: Friday, February 21, 2003 5:25 PM
Subject: Re: [PIC]: How to do token pasting in MPASM?


> On Friday 21 February 2003 04:51 am, Sergio Masci wrote:
> > Perhaps you could use the m4 macro processor as a preprocessor or
> > the GNU C preprocessor. You might even consider a better assembler
> > that does what you want out of the box. Maybe something that lets
> > you assign strings to assembler variables and manipulate them
> > during the course of the assembly like you would in a high level
> > language.
>
> You mean I can't assign strings to assembler variables? Ugh...

Don't know. I haven't seen anything that suggests you can. I use xcasm which
lets you do things like


menu_item   .macro    arg1, arg2

menu_item_cnt    .set    menu_item_cnt+1

vlab    .set    LABEL(STR(arg1) + "_%04X":menu_item_cnt)
vsect   .set    STR(arg1) + "_sect"
vsect2  .set    STR(arg1) + "_str_sect"

           .sect    vsect
           .db    vlab

           .sect    vsect2
vlab     .db    STRLEN(arg2), arg2

       .endm

menu_item_cnt    .set    0
       menu_item    item, "eggs"
       menu_item    item, "sugar"
       menu_item    item, "flour"

       .sect    item_sect
       .db    item_0001
       .db    item_0002
       .db    item_0003

       .sect    item_str_sect
item_0001    .db    4,"eggs"
item_0002    .db    5,"sugar"
item_0003    .db    5,"flour"


> I did consider using m4, but for what I need it's just as easy to have
> another program spit out simple MPASM syntax.
>
> As it is, I'm making a graphical state machine tool using Squeak that
> will spit out PIC code; I just need something right now.

What like a fully functional graphical state machine tool like ZMech that
already spits out PIC code?

Regards
Sergio Masci

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\21@141827 by Ned Konz

flavicon
face
On Friday 21 February 2003 10:19 am, Sergio Masci wrote:
> > As it is, I'm making a graphical state machine tool using Squeak
> > that will spit out PIC code; I just need something right now.
>
> What like a fully functional graphical state machine tool like
> ZMech that already spits out PIC code?

Something like it. However, I'll have targetable back-ends and
simulation, as well as real-time diagnostics of the target hardware.

--
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\21@150624 by Sergio Masci

picon face
----- Original Message -----
From: Ned Konz <TakeThisOuTnedEraseMEspamspam_OUTBIKE-NOMAD.COM>
To: <RemoveMEPICLISTspamTakeThisOuTMITVMA.MIT.EDU>
Sent: Friday, February 21, 2003 7:17 PM
Subject: Re: [PIC]: How to do token pasting in MPASM?


> On Friday 21 February 2003 10:19 am, Sergio Masci wrote:
> > > As it is, I'm making a graphical state machine tool using Squeak
> > > that will spit out PIC code; I just need something right now.
> >
> > What like a fully functional graphical state machine tool like
> > ZMech that already spits out PIC code?
>
> Something like it. However, I'll have targetable back-ends and
> simulation, as well as real-time diagnostics of the target hardware.

Real time diagnostics of the target hardware? Sounds interesting. Does this
mean you have some kind of emulator attached, or are you comparing the
outputs of the hardware with those generated by your simulator? Do you have
any web pages to look at?

RAOFL - ZMech can also do many different targets. The "backend" sits on top
of a meta CASE tool and is totally configurable for any target you may wish.
There is even a version that generates C/C++ code that will run directly on
a PC. The XCASM assembler used by ZMech is a meta assembler capable of being
configured for any processor syntax you like. I currently have definitions
here that allow it to process assembler source from processors such as
TMS430, 68HC11, Z80, 6502, PIC and others.

ZMech also does state machine simulation. It traces events directly on the
state diagram. It can even import generated code and use this to drive the
GUI. The XCSIM simulator used by the PIC edition of ZMech can directly
connect the simulated target to GUI mimics (you could for example attach a
virtual switch to an input port pin via some virtual wire, or even connect
the pins of multiple PICs together using virtual wire - yep it does
multiprocessor simulation as well). XCSIM can even do source level debugging
of code compiled with the XCSB compiler.

Regards
Sergio Masci
http://www.xcprod.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\21@153455 by Ned Konz

flavicon
face
On Friday 21 February 2003 12:11 pm, Sergio Masci wrote:
{Quote hidden}

The hardware can send state transition data to the host. As long as
the state transitions don't come too fast, this can help debug.

I don't have any web pages up yet, but I will have an early release
available to play with some time in the near future if my consulting
work doesn't tie me up too completely.

{Quote hidden}

Yes, ZMech looks like a nice tool.

--
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

2003\02\21@172413 by Sergio Masci

picon face
----- Original Message -----
From: Ned Konz <RemoveMEnedEraseMEspamEraseMEBIKE-NOMAD.COM>
To: <RemoveMEPICLISTspam_OUTspamKILLspamMITVMA.MIT.EDU>
Sent: Friday, February 21, 2003 8:32 PM
Subject: Re: [PIC]: How to do token pasting in MPASM?


{Quote hidden}

I look forward to seeing something

Regards
Sergio Masci

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads

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