Go to Post Theory is a nice place, I'd like to go there one day. - JamesCH95 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 21-07-2005, 10:50
red_alert_13 red_alert_13 is offline
Registered User
AKA: Patrick Frampton
no team (Red Alert)
Team Role: Programmer
 
Join Date: Jul 2005
Rookie Year: 2005
Location: Greenwood, Indiana
Posts: 6
red_alert_13 is an unknown quantity at this point
Assembly code in C?

I have a quick question: is it possible to use assembly code in C?

My experience was that in C++ (oh, how I miss C++), you could have code like this:

Code:
_asm
{
     /* Assembly code goes here */
}
I was wondering if the same thing would be possible with the compiler supplied by FIRST?

Thanks in advance!
  #2   Spotlight this post!  
Unread 21-07-2005, 11:54
Dave Flowerday Dave Flowerday is offline
Software Engineer
VRC #0111 (Wildstang)
Team Role: Engineer
 
Join Date: Feb 2002
Rookie Year: 1995
Location: North Barrington, IL
Posts: 1,366
Dave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond reputeDave Flowerday has a reputation beyond repute
Re: Assembly code in C?

Quote:
Originally Posted by red_alert_13
I was wondering if the same thing would be possible with the compiler supplied by FIRST?
This is called 'inline assembly' and is a nonstandard feature of most compilers, and they all seem to implement it in a slightly different way. Luckily, though, you don't have to look any further than the default code to find an example.

From ifi_startup.c:
Code:
void _startup (void)
{
  _asm
    /* Initialize the stack pointer */
    lfsr 1, _stack lfsr 2, _stack clrf TBLPTRU, 0 /* 1st silicon doesn't do this on POR */
    bcf  FPFLAGS,RND,0 /* Initialize rounding flag for floating point libs */

    /* initialize the flash memory access configuration. this is harmless */
    /* for non-flash devices, so we do it on all parts. */
    bsf 0xa6, 7, 0
    bcf 0xa6, 6, 0
  _endasm

loop:

    Clear_Memory();
  _do_cinit ();
  /* Call the user's main routine */
  main ();

  goto loop;
}                               /* end _startup() */
There's several other examples in that file as well.
  #3   Spotlight this post!  
Unread 21-07-2005, 13:23
red_alert_13 red_alert_13 is offline
Registered User
AKA: Patrick Frampton
no team (Red Alert)
Team Role: Programmer
 
Join Date: Jul 2005
Rookie Year: 2005
Location: Greenwood, Indiana
Posts: 6
red_alert_13 is an unknown quantity at this point
Re: Assembly code in C?

Thanks for your response! That clears up a lot of questions.
  #4   Spotlight this post!  
Unread 21-07-2005, 15:01
red_alert_13 red_alert_13 is offline
Registered User
AKA: Patrick Frampton
no team (Red Alert)
Team Role: Programmer
 
Join Date: Jul 2005
Rookie Year: 2005
Location: Greenwood, Indiana
Posts: 6
red_alert_13 is an unknown quantity at this point
Re: Assembly code in C?

Just in case anyone else might find assembly code useful, I found a link containing a list of commands - I'll have to test it but from the source code I've seen these are the commands used to program low level functions for the robot controller.

http://www.picbasic.co.uk/forum/showthread.php?t=222
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Out of the Box Camera Code russell Programming 9 21-10-2009 05:28
Code suddenly fails to initialize miketwalker Programming 11 19-02-2005 15:23
Team THRUST - Kevin's Code and Camera Code Combine Chris_Elston Programming 3 31-01-2005 22:28
Sourceforge for Code Repository and other stuff SilverStar Programming 9 15-01-2005 21:16
heres the code. y this not working omega Programming 16 31-03-2004 15:18


All times are GMT -5. The time now is 10:57.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi