C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 29th, 2006, 03:31 AM
slypopoxy slypopoxy is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 10 slypopoxy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 10 m 3 sec
Reputation Power: 0
C and Assembly

I am new to the assembly world. I am trying to use assembly with C . how do i integrate assemmbly with C.
How do i pass the parameter.
How do i access the arrays passed to the assemlby part of the program.
I am using İntel- base and NASM under Linux

Reply With Quote
  #2  
Old March 29th, 2006, 09:20 AM
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Apr 2004
Posts: 1,676 Dave Sinkula User rank is First Lieutenant (10000 - 20000 Reputation Level)Dave Sinkula User rank is First Lieutenant (10000 - 20000 Reputation Level)Dave Sinkula User rank is First Lieutenant (10000 - 20000 Reputation Level)Dave Sinkula User rank is First Lieutenant (10000 - 20000 Reputation Level)Dave Sinkula User rank is First Lieutenant (10000 - 20000 Reputation Level)Dave Sinkula User rank is First Lieutenant (10000 - 20000 Reputation Level)Dave Sinkula User rank is First Lieutenant (10000 - 20000 Reputation Level)Dave Sinkula User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 3 Days 8 h 23 m 46 sec
Reputation Power: 132
__________________
Any advertisement triggered by IntelliTxt in this post is not endorsed by the author of this post.

Reply With Quote
  #3  
Old March 30th, 2006, 09:25 AM
para45's Avatar
para45 para45 is offline
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Posts: 264 para45 User rank is First Lieutenant (10000 - 20000 Reputation Level)para45 User rank is First Lieutenant (10000 - 20000 Reputation Level)para45 User rank is First Lieutenant (10000 - 20000 Reputation Level)para45 User rank is First Lieutenant (10000 - 20000 Reputation Level)para45 User rank is First Lieutenant (10000 - 20000 Reputation Level)para45 User rank is First Lieutenant (10000 - 20000 Reputation Level)para45 User rank is First Lieutenant (10000 - 20000 Reputation Level)para45 User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 6 Days 2 h 28 m 19 sec
Reputation Power: 123
I know this isn't really what you asked, but GCC has an inline assembler option.

There's a little tutorial about it here:
http://www.ibiblio.org/gferg/ldp/GC...mbly-HOWTO.html

To enter an ASM block in C code with GCC, you could do:
Code:
char* str = "abc %i\n";

int main() {
    ...
    __asm__ (
        "pushl $123\n"
        "pushl str\n"
        "call printf\n"
    );
    ...
}

Which would printf abc 123.

There is also an extended ASM option which allows you to use C variables, where the compiler will translate the actual addresses and such for you, then insert them into your given ASM code template.

Syntax is a little different from Intel's, but it's not too bad, and it's convenient to use inline to experiment.

Reply With Quote
  #4  
Old March 30th, 2006, 09:50 AM
Zoso's Avatar
Zoso Zoso is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: France
Posts: 53 Zoso User rank is Corporal (100 - 500 Reputation Level)Zoso User rank is Corporal (100 - 500 Reputation Level)Zoso User rank is Corporal (100 - 500 Reputation Level)Zoso User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 47 m 5 sec
Reputation Power: 13
Here are some good tutorials on Assembly languages :

http://www.freeprogrammingresources.com/assembly.html

Most particularly, I recommend you to read http://savannah.nongnu.org/download/pgubook/ProgrammingGroundUp-1-0-booksize.pdf
Although it uses the AT&T syntax, it provides a lot of useful information, especially on the C calling convention and stackframe

Here is a link to another book with examples written in NASM : http://www.drpaulcarter.com/pcasm/

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > C and Assembly

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap