1 Replies - 1522 Views - Last Post: 02 March 2009 - 08:18 PM

#1 William_Wilson   User is offline

  • lost in compilation
  • member icon

Reputation: 207
  • View blog
  • Posts: 4,812
  • Joined: 23-December 05

Inline Assembly (with C)

Posted 24 June 2006 - 09:30 AM

Description: This method is simple, but be careful in large programs to use the stack as the compiler may use the registers as well. Try to avoid using the EBX register as it is a pointer register.How to write assembly straight into a C program for a mix of high and low level coding.
/*The best example is with a few simple variable movements */
void average(int n, int p){      
    asm(
        mov AX,n     // ;get first argument 
     mov CX,p     // ;get second argument
     add AX,CX     // ;AX = AX + CX
        div AX,2        // ;AX = AX/2
    );
}
some operations are not done perfectly when converted in
high level languages, so help them out by writting
the code's assembly yourself
*/

/*This code is not a reasonable example, but it gives the inline idea */


Is This A Good Question/Topic? 0
  • +

Replies To: Inline Assembly (with C)

#2 carltech   User is offline

  • What did you call me?
  • member icon

Reputation: 28
  • View blog
  • Posts: 997
  • Joined: 19-October 07

Re: Inline Assembly (with C)

Posted 02 March 2009 - 08:18 PM

nice demo
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1