C programs with asm statements

This is a discussion on C programs with asm statements within the C Programming forums, part of the General Programming Boards category; when i am trying to compile a c program with asm code as follows tcc -emasm.exe stop.c it is not ...

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    6

    C programs with asm statements

    when i am trying to compile a c program with asm code as follows

    tcc -emasm.exe stop.c

    it is not compiling.

    how should i do it?

  2. #2
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680

  3. #3
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    Do you really need to add "-emasm.exe"? I don't know how your compiler handles inline assembly, but some compilers can do it without an external assembler.

  4. #4
    Registered User bljonk's Avatar
    Join Date
    Oct 2001
    Posts
    70

    #asm

    if u use djgpp u maybe capable of using the preprocessor #asm

    #asm
    mov ax,5
    #endasm
    Ünicode¬>world = 10.0£

  5. #5
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    He used TCC, which is the Turbo C Compiler if I am correct. How did you use the inline assembly? Can you post the code where you use it?

  6. #6
    Unregistered
    Guest

    iThink

    i think it is used the same way as the other preprocessor directives like:

    NOTE THAT #ASM ~ #ENDASM IS NOT PART OF STANDARD C WAS ACORDINGLY WITH C9X ; MUCH MORE OF COMPILER IMPLEMETATION

    #include <conio.h>
    #include <stdio.h>
    #include <ctype.h>

    int main(int argc,char *argv[])
    {
    char do;

    int cat=1,dog=2,hold;

    int *pnt_cat = &cat;
    int *pnt_dog = &dog;
    int *pnt_hold = &hold;

    printf("Enter your choice(y/n): ");
    scanf("%c", &do);
    if(tolower(do) == 'y'){
    #asm

    mov pnt_hold,dog //here i'm supposed to swap values

    mov pnt_dog,cat //suppost to do some swaping: my head

    mov pnt_cat,hold //is start hurting.

    #endasm
    printf("\ndone~\n");
    }else{
    printf("\ano swaping was exec~\n");
    }
    getch();
    return 0;
    }

    for what i know we're not supposed to pass memory addresses to memory address so we just swap the values from one address to another(that's will explain why i'm not sure about the pointers and my head really hurts now.

  7. #7
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,386
    In Borland C one can do

    Code:
    _asm {
     mov ax,bx
     blabla
    }
    The C standard says:

    The asm keyword may be used to insert assembly language directly into the translator output (6.8). The most common implementation is via a statement of the form:
    asm ( character-string-literal );

    So I think you could also do:

    Code:
    asm mov ax,bx;
    asm sub cx;
    Last edited by Shiro; 04-19-2002 at 01:57 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Using asm in C++
    By mikahell in forum C++ Programming
    Replies: 4
    Last Post: 02-25-2010, 01:32 AM
  2. Recommend upgrade path for C programs
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-22-2007, 06:32 AM
  3. I never Finish my programs :(
    By epidemic in forum C++ Programming
    Replies: 11
    Last Post: 04-02-2007, 12:35 PM
  4. Statements and Functions
    By GeekFreak in forum C++ Programming
    Replies: 5
    Last Post: 08-15-2002, 12:34 PM
  5. executing c++ programs on the web
    By gulti01 in forum C++ Programming
    Replies: 4
    Last Post: 08-12-2002, 03:12 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21