Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Visual C and assembly

Options
  • 27-03-2005 6:29pm
    #1
    Registered Users Posts: 17,574 ✭✭✭✭


    Im working on a project for college, and this is the second one involving linking C and assembly. We have full access to Visual Studio but only restricted access to Borland C++. We were showed how to link two object files in Borland C++ (the assembly module compiled under TASM) and that works fine. But how is it done in Visual Studio?

    Ive scoured the net trying to find out, but i cant find the proper info for Visual Studio. The assembly part is very short (involves reading a disk sector to a buffer) so i could either integrate the assembly code with the c code or else compile it separately.

    The assembly is 16-bit.


Comments

  • Registered Users Posts: 4,003 ✭✭✭rsynnott


    Im working on a project for college, and this is the second one involving linking C and assembly. We have full access to Visual Studio but only restricted access to Borland C++. We were showed how to link two object files in Borland C++ (the assembly module compiled under TASM) and that works fine. But how is it done in Visual Studio?

    Ive scoured the net trying to find out, but i cant find the proper info for Visual Studio. The assembly part is very short (involves reading a disk sector to a buffer) so i could either integrate the assembly code with the c code or else compile it separately.

    The assembly is 16-bit.

    Urgh, why do colleges encourage people to do horrible things like this?


  • Registered Users Posts: 1,391 ✭✭✭fatherdougalmag


    You could always 'cheat' and embed the ASM within the C code using
     asm {
            xor eax, eax
           }
    

    Have you tried just adding the ASM file to you Project? VC should recognise the extension and compile it with its assembler.

    Failing that, you'll have to introduce a pre-build step to compile the ASM file and then just add the OBJ to your Project. VC's linker should look after the rest.


  • Closed Accounts Posts: 1,567 ✭✭✭Martyr


    You should use the microsoft assembler if working with Visual Studio.

    An example of the usage for 32-bit assembly, is like:

    ml /coff /c /Cp /I* project1.asm

    link /SUBSYSTEM:WINDOWS /LIBPATH:* project1.obj project2.obj

    Where * for /I option is path of include files (if any used)
    /LIBPATH is library files..

    I've not used visual studio, so i'm not entirely sure..
    look for ml.exe in bin directory, then in console, try ml /?

    i never used masm for 16-bit code, so i can't be completely sure on how
    it is done involving c code.


  • Registered Users Posts: 17,574 ✭✭✭✭Mr. CooL ICE


    rsynnott wrote:
    Urgh, why do colleges encourage people to do horrible things like this?
    Because the course isnt necessarily software engineering, it includes a lot of preparation for embedded systems, so low level crap like this is essential.

    My main problem with integrating the code is that when i include any instruction where i call an interrupt (eg, int 21h), the compiler detects the 'int' part as being a reserved word, despite it being wrapped in curly brackets preceded with 'asm'.

    Luckily enough, i was just given borland c++ on cd (illegally copied software is bad, but its for educational use only) so everything is made just a little bit easier.


  • Registered Users Posts: 1,994 ✭✭✭lynchie


    Luckily enough, i was just given borland c++ on cd (illegally copied software is bad, but its for educational use only) so everything is made just a little bit easier.

    You are aware that Borland C++ 5.5 compiler is FREE to download from Borland's website? You just need to register for it. Of course, you dont get an IDE with it, but Im sure you can download an IDE off the web.


  • Advertisement
Advertisement