Author Topic: How to compile ASM file with Visual Studio Compiler  (Read 16562 times)

Offline skirby

  • Almost regular
  • **
  • Posts: 137
How to compile ASM file with Visual Studio Compiler
« on: November 12, 2010, 05:06:31 pm »
Hello,

I would like to know the way to compile ASM file in Code::Blocks with Visual Studio 2010 Compiler.

I am able to compile a simple project with Visual Studio 2010 with one ASM file.
To do this, I simply modified file's properties with the following commands:
- Right click on asm file (in Solution Explorer) and Item Type set to "Custom Build Tool" (and apply changes)
- Now in "Custom Build Tool / General" tab I put :
Command Line: ml -c "-Fl$(IntDir)%(FileName).lst" "-Fo$(IntDir)%(FileName).obj" "%(FullPath)"
Outputs: $(IntDir)%(FileName).obj;%(Outputs)

With these parameters, I can right click on .asm file in Solution Explorer and select "Compile" and it compile well!

What is the way to do the same thing in Code::Blocks?

Thanks in advance and have a nice day.


skirby

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline skirby

  • Almost regular
  • **
  • Posts: 137
Re: How to compile ASM file with Visual Studio Compiler
« Reply #2 on: November 15, 2010, 02:20:13 pm »
Hello stahta01,

Thanks for your response and sorry for the delay of mine.

I think it is exactly what I need  :D

Here is what I have tried in menu "Compiler and debugger settings", tab "Other settings" and button "Advanced options..."

Command Line Macro:
Code
ml /nologo /c "/Fo$objects_output_dir$file_name.obj" "$file_dir$file"

And "Generated Files" is stayed empty.

Do you think it is ok like that?
My project compile successfully (and my exe file is generated) but I would be sure that all is OK.
For example, is it normal that I do not have to fill the "Generated Files" text box?

Below you will find files that I used to make my tests.

Thanks and have a nice day.

main.cpp file :
Code
#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <stdio.h>


extern "C" int __cdecl sub_test(void);

//int main(void)
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil)
{
    char s[255] = "";
    int a = 5;

    a = sub_test();
    sprintf_s(s,"a = %d", a);
    MessageBox(0, s, "Information", MB_ICONINFORMATION);

    return(0);
}

function.asm file:
Code
.386
.model flat, c ; cdecl / stdcall
option casemap :none

.data

.code

sub_test    proc
    push    ebp
    mov     ebp, esp

    mov     eax, 8

    leave
;    mov     ebp, esp
;    push    ebp
    ret
sub_test    endp

end