plz help in assembling these programs

Started by sprint, January 21, 2009, 06:13:11 PM

Previous topic - Next topic

sprint

hello everybody m new to the world of Assembly language and i just got the feel of programming in Assembly .

asif

ToutEnMasm

ML must know where is io.mac file.It's an include file.use a bath file (.bat) like this.

Quote
@echo on
SET PATH=C:\MASM32\BIN
SET LIB=C:\MASM32\LIB
SET INCLUDE=C:\MASM32\INCLUDE;"Path on io.mac file"
SET ML=/c /coff /nologo /safeseh
SET LINK=/SUBSYSTEM:WINDOWS /NOLOGO
SET FICHIER=MY_EXE
del *.pdb
del *.ilk
del *.obj
del *.exe

rc /v %FICHIER%.rc
cvtres /machine:ix86 /OUT:%FICHIER%.zzz %FICHIER%.res
pause
ml /Zi /Zd %FICHIER%.asm

pause
Link /SUBSYSTEM:WINDOWS /DEBUG /PDB:minus.pdb %FICHIER%.obj %FICHIER%.zzz
pause

Replace "Path on io.mac file" by his value.

More explain ?.Give more informations on how you compile your files.


dedndave

Hi asif,
   I am new to assembly programming for windows 32-bit. However, I have been writing assembly language programs for many years.
I prefer MASM, which is microsoft's assembler. The old one I used for 16-bit programming was fairly simple. The newer one for 32-bit programming is quite complex. In fact, programming for windows 32-bit seems rather complicated to me right now. If I were totally new to assembly language, I would choose a simpler assembler program to start out with. I think FASM might be a good choice.
There are several others; NASM, GoAsm, and others.
   One thing that I see in the batch file you gave us, is the command "Set Path=C:\MASM32\BIN". This command is the reason I am replying to your post. Your computer already has some other folders in the Path statement. If you execute the command as shown, the only folder in the Path will be C:\MASM32\BIN. All the others will be lost. To add a folder to the Path without destroying all the
other references, it should look like this "Set Path=%Path%;C:\MASM32\BIN". That way, it adds the masm32\bin folder to the list without removing all the others.
    I hope this helps - Dave


rags

Wouldn't setlocal also work, since the environment variables
would only be set for the duration of the batch file?
God made Man, but the monkey applied the glue -DEVO

MichaelW

From the PSDK:
Quote
Environment variables specify search paths for files, directories for temporary files, application-specific options, and other similar information. The system maintains an environment block for each user and one for the computer. The system environment block represents environment variables for all users of the particular computer. A user's environment block represents the environment variables the system maintains for that particular user, including the set of system environment variables.
...
By default, each process receives a copy of the environment block for its parent process. Typically, this is the environment block for the user who is logged on.
...
The user can also add or modify environment variables at a command prompt using the set command. Environment variables created with the set command apply only to the command window in which they are set, and to its child processes.
eschew obfuscation

sprint

dear All

i tried assembling the programs from the text Dandamundi but failed to get any output again.The instructions given here on this forum couldn't help me to assemble the programs hence i request u all to have  look at the link below and read the pdf and other files .i setup the environment variables and also including the file IO.MAC...but all these attempts tuned futile.

here is the link for the programs by the author  i would like to assemble and run under windows (MASM32 and NASM)

http://www.scs.carleton.ca/~sivarama/asm_book/

and i am using the 16 bit linker as directed  by the author
thanking u
regards asif
::)

dedndave

Hi Asif,
    Let's choose one program and see if we can make it work for you.
Pick one of the examples and tell us which one it is.
Then, tell us exactly what happens when you try to assemble it.
Tell us the errors, etc that the assembler and/or linker display.
I think if we can get one to work for you, they all will.
- Dave

Lupo1989

Here i made my own bat file how is easy to config maybe you can just it also.. if you find any bug mail me;)

Greeze Lupo


@echo off

Set Compiler_Dir=C:\MASM32\BIN

Set App_type=WINDOWS
Set App_Ext=EXE
Set File_ASM=OOP1
Set File_OBJ_Propeties=/c /coff /Cp
Set File_RC=Resource\Objects\Window\Window
Set File_REC_Propeties=/v
Set File_REC=
set File_Def=
set Output_File_Name=Application


echo -------------------------------------------------------------------------
echo - Compiler Settings:
If exist "%Compiler_Dir%\Ml.exe" echo - Ml.exe = %Compiler_Dir%\Ml.exe
If not exist "%Compiler_Dir%\Ml.exe" echo - Ml.exe = FILE NOT FOUND!!!
If exist "%Compiler_Dir%\Rc.exe" echo - Rc.exe = %Compiler_Dir%\Rc.exe
If not exist "%Compiler_Dir%\Rc.exe" echo - Rc.exe = FILE NOT FOUND!!!
If exist "%Compiler_Dir%\Link.exe" echo - Link.exe = %Compiler_Dir%\Link.exe
If not exist "%Compiler_Dir%\Link.exe" echo - Link.exe = FILE NOT FOUND!!!
echo -------------------------------------------------------------------------
If not exist "%Compiler_Dir%\Ml.exe" echo -------------------------------------------------------------------------
If not exist "%Compiler_Dir%\Ml.exe" echo - Het bestand '%Compiler_Dir%\Ml.exe' bestaat niet!!!
If not exist "%Compiler_Dir%\Ml.exe" echo - Compilen is niet gelukt!!!
If not exist "%Compiler_Dir%\Ml.exe" echo -------------------------------------------------------------------------
If not exist "%Compiler_Dir%\Ml.exe" pause
If not exist "%Compiler_Dir%\Ml.exe" GoTo :EXIT

If not exist "%Compiler_Dir%\Rc.exe" echo -------------------------------------------------------------------------
If not exist "%Compiler_Dir%\Rc.exe" echo - Het bestand '%Compiler_Dir%\Rc.exe' bestaat niet!!!
If not exist "%Compiler_Dir%\Rc.exe" echo - Compilen is niet gelukt!!!
If not exist "%Compiler_Dir%\Rc.exe" echo -------------------------------------------------------------------------
If not exist "%Compiler_Dir%\Rc.exe" pause
If not exist "%Compiler_Dir%\Rc.exe" GoTo :EXIT

If not exist "%Compiler_Dir%\Link.exe" echo -------------------------------------------------------------------------
If not exist "%Compiler_Dir%\Link.exe" echo - Het bestand '%Compiler_Dir%\Link.exe' bestaat niet!!!
If not exist "%Compiler_Dir%\Link.exe" echo - Compilen is niet gelukt!!!
If not exist "%Compiler_Dir%\Link.exe" echo -------------------------------------------------------------------------
If not exist "%Compiler_Dir%\Link.exe" pause
If not exist "%Compiler_Dir%\Link.exe" GoTo :EXIT

echo -------------------------------------------------------------------------
echo - Settings:
echo - Application = %App_type%
echo - Excension = %App_Ext%
If exist "%File_ASM%.asm" echo - Assembly File = %File_ASM%.asm
If not exist "%File_ASM%.asm" echo - Assembly File = FILE NOT FOUND!!!
If exist "%File_RC%.rc" echo - Resource File = %File_RC%.rc
If exist "%File_REC%.rc" echo - Compiled Resource File = %File_REC%.RES
If exist "%File_Def%.def" echo - Def File = %File_RC%.def
echo -
echo - Output File = %Output_File_Name%.%App_Ext%
echo -------------------------------------------------------------------------

If not exist "%File_ASM%.asm" echo -------------------------------------------------------------------------
If not exist "%File_ASM%.asm" echo - Het bestand '%File_ASM%.asm' bestaat niet!!!
If not exist "%File_ASM%.asm" echo - Compilen is niet gelukt!!!
If not exist "%File_ASM%.asm" echo -------------------------------------------------------------------------
If not exist "%File_ASM%.asm" pause
If not exist "%File_ASM%.asm" GoTo :EXIT

GoTo :START

:START
GoTo :STAP_1_COMPILE_ASM_TO_OBJ

:STAP_1_COMPILE_ASM_TO_OBJ
If not exist "%File_ASM%.asm" echo -------------------------------------------------------------------------
If not exist "%File_ASM%.asm" echo - Het bestand '%File_ASM%.asm' bestaat niet!!!
If not exist "%File_ASM%.asm" echo - Compilen is niet gelukt!!!
If not exist "%File_ASM%.asm" echo -------------------------------------------------------------------------
If not exist "%File_ASM%.asm" pause
If not exist "%File_ASM%.asm" GoTo :EXIT

echo -------------------------------------------------------------------------
echo - Command: "%Compiler_Dir%\Ml.exe" %File_OBJ_Propeties% "%File_ASM%.asm"
echo -------------------------------------------------------------------------
"%Compiler_Dir%\Ml.exe" %File_OBJ_Propeties% "%File_ASM%.asm"

If not exist "%File_ASM%.obj" echo -------------------------------------------------------------------------
If not exist "%File_ASM%.obj" echo - Het bestand '%File_ASM%.obj' bestaat niet!!!
If not exist "%File_ASM%.obj" echo - Compilen is niet gelukt!!!
If not exist "%File_ASM%.obj" echo -------------------------------------------------------------------------
If not exist "%File_ASM%.obj" pause
If not exist "%File_ASM%.obj" GoTo :EXIT

If exist "%File_RC%.rc" GoTo :STAP_2_COMPILE_RC_TO_REC
if "%App_Ext%"=="DLL" GoTo :STAP_3_CHECK_DEF
If exist "%File_REC%.res" GoTo :STAP_4_EXE_REC
If not exist "%File_RC%.rc" GoTo :STAP_4_EXE_NO_RESOURCE


:STAP_2_COMPILE_RC_TO_REC
If not exist "%File_RC%.rc" echo -------------------------------------------------------------------------
If not exist "%File_RC%.rc" echo - Het bestand '%File_RC%.rc' bestaat niet!!!
If not exist "%File_RC%.rc" echo - Compilen is niet gelukt!!!
If not exist "%File_RC%.rc" echo -------------------------------------------------------------------------
If not exist "%File_RC%.rc" pause
If not exist "%File_RC%.rc" GoTo :EXIT

If exist "%File_RC%.rc" echo -------------------------------------------------------------------------
If exist "%File_RC%.rc" echo - Command: "%Compiler_Dir%\Rc.exe" %File_REC_Propeties% "%File_RC%.rc"
If exist "%File_RC%.rc" echo -------------------------------------------------------------------------
If exist "%File_RC%.rc" "%Compiler_Dir%\Rc.exe" %File_REC_Propeties% "%File_RC%.rc"

If not exist "%File_RC%.res" echo -------------------------------------------------------------------------
If not exist "%File_RC%.res" echo - Het bestand '%File_RC%.res' bestaat niet!!!
If not exist "%File_RC%.res" echo - Compilen is niet gelukt!!!
If not exist "%File_RC%.res" echo -------------------------------------------------------------------------
If not exist "%File_RC%.res" pause
If not exist "%File_RC%.res" GoTo :EXIT

if "%App_Ext%"=="DLL" GoTo :STAP_3_CHECK_DEF
if "%App_Ext%"=="EXE" GoTo :STAP_4_EXE_RESOURCE

:STAP_3_CHECK_DEF
If not exist "%File_Def%.def" echo -------------------------------------------------------------------------
If not exist "%File_Def%.def" echo - Het bestand '%File_Def%.def' bestaat niet!!!
If not exist "%File_Def%.def" echo - Compilen is niet gelukt!!!
If not exist "%File_Def%.def" echo -------------------------------------------------------------------------
If not exist "%File_Def%.def" pause
If not exist "%File_Def%.def" GoTo :EXIT

If exist "%File_RC%.res" GoTo :STAP_4_DLL_RESOURCE
If not exist "%File_RC%.res" GoTo :STAP_4_DLL_NO_RESOURCE

:STAP_4_DLL_RESOURCE
echo -------------------------------------------------------------------------
echo - Command: "%Compiler_Dir%\Link.exe" /DLL /DEF:"%File_Def%.def" /SUBSYSTEM:"%App_type%" /OUT:"%Output_File_Name%.dll" "%File_ASM%.obj" "%File_RC%.rec"
echo -------------------------------------------------------------------------
"%Compiler_Dir%\Link.exe" /DLL /DEF:"%File_Def%.def" /SUBSYSTEM:"%App_type%" /OUT:"%Output_File_Name%.dll" "%File_ASM%.obj"
GoTo :STAP_5_DELETE_TEMPORY_FILES

:STAP_4_DLL_NO_RESOURCE
echo -------------------------------------------------------------------------
echo - Command: "%Compiler_Dir%\Link.exe" /DLL /DEF:"%File_Def%.def" /SUBSYSTEM:"%App_type%" /OUT:"%Output_File_Name%.dll" "%File_ASM%.obj"
echo -------------------------------------------------------------------------
"%Compiler_Dir%\Link.exe" /DLL /DEF:"%File_Def%.def" /SUBSYSTEM:"%App_type%" /OUT:"%Output_File_Name%.dll" "%File_ASM%.obj"
GoTo :STAP_5_DELETE_TEMPORY_FILES

:STAP_4_EXE_RESOURCE
echo -------------------------------------------------------------------------
echo - Command: "%Compiler_Dir%\Link.exe" /SUBSYSTEM:"%App_type%" /OUT:"%Output_File_Name%.exe"  "%File_ASM%.obj" "%File_RC%.res"
echo -------------------------------------------------------------------------
"%Compiler_Dir%\Link.exe" /SUBSYSTEM:"%App_type%" /OUT:"%Output_File_Name%.exe" "%File_ASM%.obj" "%File_RC%.res"
GoTo :STAP_5_DELETE_TEMPORY_FILES

:STAP_4_EXE_REC
echo -------------------------------------------------------------------------
echo - Command: "%Compiler_Dir%\Link.exe" /SUBSYSTEM:"%App_type%" /OUT:"%Output_File_Name%.exe" "%File_ASM%.obj" "%File_REC%.res"
echo -------------------------------------------------------------------------
"%Compiler_Dir%\Link.exe" /SUBSYSTEM:"%App_type%" /OUT:"%Output_File_Name%.exe" "%File_ASM%.obj" "%File_REC%.res"
GoTo :STAP_5_DELETE_TEMPORY_FILES

:STAP_4_EXE_NO_RESOURCE
echo -------------------------------------------------------------------------
echo - Command: "%Compiler_Dir%\Link.exe" /SUBSYSTEM:"%App_type%" /OUT:"%Output_File_Name%.exe" "%File_ASM%.obj"
echo -------------------------------------------------------------------------
"%Compiler_Dir%\Link.exe" /SUBSYSTEM:"%App_type%" /OUT:"%Output_File_Name%.exe" "%File_ASM%.obj"
GoTo :STAP_5_DELETE_TEMPORY_FILES

:STAP_5_DELETE_TEMPORY_FILES
echo -------------------------------------------------------------------------
If exist "%File_ASM%.obj" echo - Command: del "%File_ASM%.obj"
If exist "%File_ASM%.obj" del "%File_ASM%.obj"
:IF1
If not exist "%File_RC%.rc" GoTo :ENDIF1
If exist "%File_RC%.res" echo - Command: del "%File_RC%.res"
If exist "%File_RC%.res" del "%File_RC%.res"
:ENDIF1
If exist "%File_RC%.obj" echo - Command: del "%File_RC%.obj"
If exist "%File_RC%.obj" del "%File_RC%.obj"
If exist "%File_ASM%.exp" echo - Command: del "%File_ASM%.exp"
If exist "%File_ASM%.exp" del "%File_ASM%.exp"
If exist "%File_ASM%.lib" echo - Command: del "%File_ASM%.lib"
If exist "%File_ASM%.lib" del "%File_ASM%.lib"
echo -------------------------------------------------------------------------

if %App_Ext%==EXE GoTo :EXECUTE_PROGRAM
if %App_Ext%==DLL GoTo :DLL_CHECK

:EXECUTE_PROGRAM
If not exist "%Output_File_Name%.exe" echo -------------------------------------------------------------------------
If not exist "%Output_File_Name%.exe" echo - Het bestand '%Output_File_Name%.exe' bestaat niet!!!
If not exist "%Output_File_Name%.exe" echo - Compilen is niet gelukt!!!
If not exist "%Output_File_Name%.exe" echo -------------------------------------------------------------------------
If not exist "%Output_File_Name%.exe" pause
If not exist "%Output_File_Name%.exe" GoTo :EXIT

echo -------------------------------------------------------------------------
echo - Command: "%Output_File_Name%.exe"
echo -------------------------------------------------------------------------
"%Output_File_Name%.exe"

GoTo :EXIT

:DLL_CHECK
If not exist "%Output_File_Name%.dll" echo -------------------------------------------------------------------------
If not exist "%Output_File_Name%.dll" echo - Het bestand '%Output_File_Name%.dll' bestaat niet!!!
If not exist "%Output_File_Name%.dll" echo - Compilen is niet gelukt!!!
If not exist "%Output_File_Name%.dll" echo -------------------------------------------------------------------------

If exist "%Output_File_Name%.dll" echo -------------------------------------------------------------------------
If exist "%Output_File_Name%.dll" echo - Output: %Output_File_Name%.dll
If exist "%Output_File_Name%.dll" echo - Compilen is gelukt!!!
If exist "%Output_File_Name%.dll" echo -------------------------------------------------------------------------

pause
GoTo :EXIT
:EXIT