For small pieces of code in assembler for me is very comfortable to put them in batch file and compile directly or in remote Windows machine.
This is my working .bat file designed to work with MASM32
;@goto end
.486
.model flat,stdcall
option casemap:none
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
.data
msg db "Hello Word",0
.code
start:
push 0
push offset msg
push offset msg
push 0
call MessageBox
push 0
call ExitProcess
end start
:end
@echo off
set name=%~n0
set cmpname=ml.exe
set linkname=link.exe
for %%X in (%cmpname%) do (set CMPL=%%~$PATH:X)
if defined CMPL (
for %%I in (%linkname%) do (set MLINK=%%~$PATH:I)
if defined MLINK (
%CMPL% /nologo /c /coff /Cp %name%.bat
%MLINK% /SUBSYSTEM:WINDOWS /FIXED:NO %name%.obj
del *.obj
) ELSE (
ECHO Cannot find %linkname% !
)
) ELSE (
ECHO Cannot find %cmpname% !
)
exit /b %ERRORLEVEL%
My problem:
for example, when trying to work with GCC
;@goto end
#include <stdio.h>
int main()
{
return 0;
}
:end
;@echo off
set name=%~n0
set cmpname=gcc.exe
for %%I in (%cmpname%) do (set CMPL=%%~$PATH:I)
if defined CMPL (
%CMPL% -Wall -o %name% %name%.bat
del *.obj
) ELSE (
echo Cannot find %cmpname% !
)
exit /b %ERRORLEVEL%
first error:
\CodeBlocks\MinGW\bin\gcc.exe was unexpected at this time.
I searched and found this , then I changed to the:
for %%I in (%cmpname%) do (set CMPL="%%~$PATH:I")
solve it, but have a new error:
testc.bat: file not recognized:
File format not recognized
collect2.exe: error: ld returned 1 exit status
My question is:
Is it possible and how to make above mentioned batch file to work with C/C++ compilers ?