Thread: using c/c++ with other languages(asm)

  1. #1
    Registered User
    Join Date
    Jan 2002
    Posts
    69

    using c/c++ with other languages(asm)

    Could anyone tell me how i could use c/c++ with other languages like asm or pascal and i'd especially like if anyone could give me tutorials on using asm and c/c++. or source code with asm inlined in c/c++. it'd be good if u can give me some source on how to do little things that are helpful with asm inlined in c/c++ thanks if u can answer this question.

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    if you are using Visual C++ you can use an asm block, looks like this:

    Code:
    __asm {
        MOV AX,BX
        ADD AX,BX
    };
    OR you can go like this:

    Code:
    __asm MOV AX,BX
    __asm ADD AX,BX
    "There are three kinds of people in the world...
    Those that can count and those that can't."

  3. #3
    Just because ygfperson's Avatar
    Join Date
    Jan 2002
    Posts
    2,490
    Originally posted by Salem
    Such details are by their nature compiler specific - each has their own way of doing this (if they do it at all).

    So it's best to start by Reading The Manual
    ditto. if you're using gcc and wanting to use intel-style assembly (to give an example):

    1)nasm -f elf assem.asm
    (you might want to change elf to coff if in DOS or windows.)
    2)g++ -o exefile exefile.cpp assem.o

    in the nasm file, you need to keep your functions c++ compatable. assem.asm should look somewhat like
    Code:
    global RetMsg__Fl
    RetMsg__Fl:
    push ebp
    mov ebp,esp
    
    ...
    
    mov esp,ebp
    pop ebp
    ret
    even these rules change a bit going from linux to dos. you need basically do what salem says.

Popular pages Recent additions subscribe to a feed