News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

How to compile ASM file with Visual Studio Compiler

Started by skirby, November 12, 2010, 05:06:31 PM

Previous topic - Next topic

skirby

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

stahta01

C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

skirby

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:
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 :
#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:
.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