Searching \ for '[PIC] mixing asm block and C ?' 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: 'mixing asm block and C ?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC] mixing asm block and C ?'
2006\05\03@202732 by fsdfsdds sfsdfssdf

picon face
I need to access a 'C' variable in an _asm _endasm block.

For example:

static byte a;

a=10

_asm
English pesudo code: increase 'a' by 1
_endasm

_________________________________________________________________
Are you using the latest version of MSN Messenger? Download MSN Messenger
7.5 today! http://join.msn.com/messenger/overview

2006\05\03@205925 by Timothy Weber

face picon face
fsfsdfsdds sfsdfssdf wrote:
> I need to access a 'C' variable in an _asm _endasm block.
>
> For example:
>
> static byte a;
>
> a=10
>
> _asm
> English pesudo code: increase 'a' by 1
> _endasm

Depends on what C compiler you're using.

Some use a convention like "movf _a, f".
--
Timothy J. Weber
http://timothyweber.org

2006\05\04@054746 by fsdfsdds sfsdfssdf

picon face
I am using mcc

_________________________________________________________________
The new MSN Search Toolbar now includes Desktop search!
http://join.msn.com/toolbar/overview

2006\05\04@080545 by Walter Banks

picon face
All C variables are accessible from asm by name in MPC . In MPC C and the inline assembler share the same symbol table.

Walter ..


fsfsdfsdds sfsdfssdf wrote:

{Quote hidden}

> -

2006\05\04@094022 by fsdfsdds sfsdfssdf

picon face


>All C variables are accessible from asm by name in MPC . In MPC C and the
>inline assembler share the same symbol table.

I know they are available, the question is how to add 1 to a?

_________________________________________________________________
Are you using the latest version of MSN Messenger? Download MSN Messenger
7.5 today! http://join.msn.com/messenger/overview

2006\05\04@100134 by Walter Banks

picon face
The following code fragment shows both C and asm code to add 1 to a

w..
========================================
0033                              int a;

                                 void main (void)
                                  {
0018 1283    BCF    STATUS,RP0       a++;
0019 0AB3    INCF   33

001A 3005    MOVLW  05h              a = a + 5;
001B 07B3    ADDWF  33
                                 #asm
001C 0AB3                  INCF  a


001D 3001                  MOVLW  1
001E 07B3                  ADDWF  a
                                 #endasm

001F 0008    RETURN                }



fsfsdfsdds sfsdfssdf wrote:

> >All C variables are accessible from asm by name in MPC . In MPC C and the
> >inline assembler share the same symbol table.
>
> I know they are available, the question is how to add 1 to a?
>
> _________________________________________________________________
> Are you using the latest version of MSN Messenger? Download MSN Messenger
> 7.5 today! http://join.msn.com/messenger/overview
>
> -

2006\05\04@102353 by dbwood

picon face
Aren't you missing the underscore, as in "_a"? Most C compilers
prepend an underscore to variable and function names.

Douglas Wood

{Original Message removed}

2006\05\04@102600 by James Newtons Massmind

face picon face
Before anyone says this in a less polite manner, please allow me to refer
you to the data sheet where a full listing of the available assembly
commands can be found. It is called the instruction set. One of them will be
about "increment" and that will be the one you want to read.

Whether that data sheet is fun or not is best decided by you and is NOT for
me to comment on.

Interesting name, by the way....

---
James Newton: PICList webmaster/Admin
spam_OUTjamesnewtonTakeThisOuTspampiclist.com  1-619-652-0593 phone
http://www.piclist.com/member/JMN-EFP-786
PIC/PICList FAQ: http://www.piclist.com




> {Original Message removed}

2006\05\04@105528 by olin piclist

face picon face
James Newtons Massmind wrote:
> Before anyone says this in a less polite manner,

D'oh!  I wasn't fast enough.

******************************************************************
Embed Inc, Littleton Massachusetts, (978) 742-9014.  #1 PIC
consultant in 2004 program year.  http://www.embedinc.com/products

2006\05\04@110932 by Walter Banks

picon face
Many C compilers see C as a preprocessor to an assembler. The MPC
C compiler compiles directly to machine code and eliminates a pass.
all of the interface issues between the assembler and  C.  ASM and C
can directly share variables. As the code fragment shows the  underscore
is not needed. There is a switch in some of Byte Craft compilers that
allows the underscore for compatibility.

w..



.....dbwoodKILLspamspam@spam@kc.rr.com wrote:

> Aren't you missing the underscore, as in "_a"? Most C compilers
> prepend an underscore to variable and function names.
>
> Douglas Wood
>
> {Original Message removed}

2006\05\04@114341 by fsdfsdds sfsdfssdf

picon face
Your code simply doesn't compile.
You say

incf a

which results in the following error message:

Error [1251] 'incf' operand count mismatch
Halting build on first failure as requested.

Is it possible to receive pure code (i.e. not from disassem)?

_________________________________________________________________
Are you using the latest version of MSN Messenger? Download MSN Messenger
7.5 today! http://join.msn.com/messenger/overview

2006\05\04@131434 by Dennis Crawley

picon face

fsfsdfsdds sfsdfssdf <carlenegreenanspamKILLspamhotmail.co.uk> wrote:
> I need to access a 'C' variable in an _asm _endasm block.


fsfsdfsdds sfsdfssdf, look into your MCC manual, somthing like this:

in Keil C (uVision):
#pragma asm
  MOV   A,r7
  SETB  TB8
  JB    P,FINAL
  CLR   TB8
FINAL:
#pragma endasm

in Hi-Tech

unsigned char var;
void main(void)
        {
          var = 1;
           #asm
             rlf  var,f
           #endasm
         }

but for "if, while, do" you must use:   asm("rlf var,f"); So It would be
better that you pick you mcc manual.

Regards,
DC




2006\05\04@143534 by dbwood

picon face
HI-TECH and IAR do not. They do require the underscore.

Douglas Wood

----- Original Message -----
From: Walter Banks <.....walterKILLspamspam.....bytecraft.com>
Date: Thursday, May 4, 2006 10:27 am
Subject: Re: [PIC] mixing _asm block and C ?
To: "Microcontroller discussion list - Public." <EraseMEpiclistspam_OUTspamTakeThisOuTmit.edu>

{Quote hidden}

MPC
{Quote hidden}

> >

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