News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

merry-go-round

Started by hell0, September 29, 2009, 12:51:49 PM

Previous topic - Next topic

hell0

greetings...

iam new to this forum and a beginner to masm32.
Downloaded the assembler masm32 from http://www.masm32.com/ .
For the  code-view dbg. i tried to access http://www.nuvisionmiami.com/books/asm/cv/cv41patch.exe, but there i get instead, a merry-go-round fling. (no offence intended, merely to cheer up my slumped spirits). May be that link is very old.

Well, the (example1.exe) is assembled, using ml/Zi instruction, and now, i need a debugger to continue with the assembly.(please suggest one 32-bit).

i seek the help here, so that i can proceed in the right direction from the very beginning. For instance:
. . .
.data
    one  db  " hell0 ! greetings ",0
    two  db  " The MASM Forum",0
.code
    start:
    push mb_ok
    push offset one
    push offset two
    push hwnd
    call MessageBoxA
    push 0
    call ExitProcess
    end start
   
the above code fragment (for tasm), calls a Message Box.
now say,  i like to start with the similar code, for a console based application in masm32 (e.g. by using 'printf' function instead of the API MessageBoxA().

this may not be the right way to begin with...so,
i need your direction, suggestions, and address's of a few related links.
thank you.

regards..

Vortex

Hi hell0,

Welcome to the Masm Forum.

Here is a quick example for you :

.386
.model flat,stdcall
option casemap:none

include     ConsoleTest.inc

.data

message1    db "This is a StdOut test.",13,10,0
message2    db "This is a printf test.",0
format1     db "%s",0

.code

start:

; The StdOut function from static library masm32.lib

    invoke  StdOut,ADDR message1

; The classical printf function
; from the C run-time library msvcrt.dll

    invoke  crt_printf,ADDR format1,ADDR message2

    invoke  ExitProcess,0

END start


About the crt prefix : it's intended to avoid naming conflicts with some reserved Masm keywords. You can check the MASM32 Library Reference to get information about functions from masm32.lib :

\masm32\help\masmlib.chm

hell0

Vortex...
many thanks for the warm winning welcome response with that very supportive
attachment of (asm exe inc and bat) files with code lines commented duly.

thank you for your taking the time to respond helpfully.
Regards...

hell0

.386
.model flat,stdcall
      option casemap:none
     
      includelib  \masm32\lib\kernel32.lib
      includelib  \masm32\lib\masm32.lib
      includelib  \masm32\lib\msvcrt.lib
     
      include     \masm32\include\kernel32.inc   ;' line no:9
      include     \masm32\include\masm32.inc
      include     \masm32\include\msvcrt.inc
     
      include     \masm32\include\windows.inc
     
.data
      message1    db "This is a StdOut test.",13,10,0
      message2    db "This is a printf test.",0
      format1     db "%s",0
     
.code
      start:
      invoke  StdOut,ADDR message1
      invoke  crt_printf,ADDR format1,ADDR message2
      invoke  ExitProcess,0
      END start

     
The above code is the one provided earlier as an example to my query. Trying to assemble it using the instruction:
< ml /c test.asm > gives me this error:
     
Assembling: test.asm
test.asm (9): fatal error A1000: cannot open file: \masm32\include\kernel32.inc
     
i suppose, ExitProcess function is exported by kernel32.lib and kernel32.inc file contains the prototype for ExitProcess,
and assembler/linker will not lend a hand in the absence of this function prototype.
So, i tried to locate it, and found that kernell32.inc is very much present at the chosen location.
     
So, it could be me that made some slip-up!!
Where did i go wrong!
...

dedndave

hi and welcome to the forum
yes - the nuvisionmiami link is from a very old revision of Randall Hyde's Art of Assembly Language
Randall is a member of our forum and pops in from time to time

as for the kernel32.inc error, that file is put into place when you install masm32
one problem you may be experiencing is if you install masm32 on one drive, then try to assemble on a different drive
that is because all of the masm32 includes are specified assuming the assembly drive is the same as the masm32 drive

hope that helps

hell0

Thank you ...dedndave !

Following your suggestion, i created a new directory (msm) in the same drive where masm is installed (c:), and tried to assemble the code, that vortex had thoughtfully provided earlier. An .obj file is made but once again, failed to create an .exe file as seen below:

        C:\msm>ml consoletest.asm
        Microsoft (R) Macro Assembler Version 6.14.8444
        Assembling: consoletest.asm
        Microsoft (R) Incremental Linker Version 5.12.8078
       
        /z2
        "consoletest.obj"
        "consoletest.exe"
        NUL
        LINK : warning LNK4044: unrecognized option "z2"; ignored
        consoletest.obj : warning LNK4033: converting object format from OMF to COFF
        LINK : fatal error LNK1181: cannot open input file "consoletest.exe"

C:\msm>dir /b
ConsoleTest.asm
ConsoleTest.inc
consoletest.obj
msm.bat

Anyway, i'll try to do everything all over again, and 'am sure i would be able to get it done correctly soon.

Regards...

dedndave

the linker has an error "opening input file consoletest.exe"
your linker command line is a bit screwy, as exe's are output files
it should be looking for consoletest.obj as an input file

here is the batch file i use
see if it works for you...

hell0

..
i appreciate your help.
but the bat file doesn't seem to be that keen to help me.

Regards...

dedndave

make sure that the 16-bit linker exe filename in the batch file matches the one you have in the masm32\bin folder

hell0

Quote..matches the one you have in the masm32\bin folder..
Link  link16  polink  These are the 3 link 'sounding' files that are visible in the bin directory.

Quote..16-bit linker exe..
i am not certain , which is the 16-bit linker here, or which one is 32 bit. 'Appearance is often deceptive' still, if forced, i would select link16 as 16-bit. Hope iam right ! see.. iam not a dumbbell always i have streaks of  brilliancy hidden !

But, iam under the impression that iam dealing with 32-bit assembly-source and i need to use a 32-bit linker. why do we talk about a 16bit linker ?  May be my notion about both source as well as linker is incorrect.

Quote..the 16-bit linker exe filename in the batch file..
There are 45 lines of material in the asc.bat file that you have uploaded.
Where in the conglomeration of (Greek and Latin), this 16-bit mythical superman is hiding in plain view! How do i locate HIM!

You've used up so much of your time to help me out with masm32 and iam grateful to you. But, iam a simple mortal... my aspiration as well as my ability are limited.

Regards...

dedndave

ok - asc.bat is for 32-bit console mode
a16.bat is for 16-bit and is very simple
the only problem is, the linker for 16-bit can be named
link16.exe
link563.exe
lnk.563
just find out which 16-bit linker you have and modify a16.bat so that it matches
then, put a16.bat into the masm32\bin folder

hell0

iam afraid there could be a communication problem, may be i failed to put across the image as it should be.
This is the beginning of 'my' source:

.386
.model flat,stdcall
option casemap:none

The directive .386 directs the assembler to follow IA-32 instructions set.
iam sure that you are very well aware of it since 1978 or even before.

So, 'my' source needs 32-bit handling. But, why are we dealing with 16-bit rigmarole. Anyway, i followed the instructions as:

1. Original a16.bat:
    if exist %1.exe del %1.exe
    c:\masm32\bin\Link563 %1.obj; >>c:\masm32\bin\asmbl.txt
   
2. Modified a16.bat:
    if exist %1.exe del %1.exe
    c:\masm32\bin\link16 %1.obj; >>c:\masm32\bin\asmbl.txt
   
3. Modified a16.bat is placed within masm32\bin folder
    C:\masm32\bin
    a16.bat
    asmbl.txt
    assmbl.bat
    lib.exe
    link.exe
    link16.exe
    ... ...
4. Files within (msm) source folder:
    C:\msm>
    ConsoleTest.asm
    ConsoleTest.inc
   
5. after this instruction to assemble:
    C:\msm> Ml ConsoleTest.asm

     Assembling: consoleTest.asm
   
    /z2
    "consoleTest.obj"
    "consoleTest.exe"
    NUL
    LINK : warning LNK4044: unrecognized option "z2"; ignored
    consoleTest.obj : warning LNK4033: converting object format from OMF to
    LINK : fatal error LNK1181: cannot open input file "consoleTest.exe"
   
The result is not very heartening but still inspirational.
Regards...     


dedndave

lol - stay with it - don't give up - or you are already beaten

first - put this line in the source file (assuming ConsoleTest.inc is required)
include c:\msm\ConsoleTest.inc

then, try this command line for the assembler.....

ML /c ConsoleTest.asm

normally - we put the inc files in masm32\include
or - in a project folder
it shouldn't matter - so long as the assembler can find it

the errors you are seeing are due to the lack of a "/c" on the ML command line
which tell the assembler it is a console mode program

hell0

Dedndave...

..with 2408 posts, you must be quite a skilled personality here. but today, 'am afraid that, may be we are beginning to lose focus.

put this line in the source file (assuming ConsoleTest.inc is required)
include c:\msm\ConsoleTest.inc

it was already included in 'my' source file which was provided by vortex, and the inc file consoleTest.inc is in the source folder.

then, try this command line for the assembler.....
ML /c ConsoleTest.asm

this command, was tried any number of times and it had created an .obj file that many number of times, without a murmur or a hiccup. so, far the effort was a breeze.

Quote"the errors you are seeing are due to the lack of a "/c" on the ML command line"
iam afraid to say that 'am not sure /convinced of this statement. i may be wrong.

The hitch begins from there onwards while trying to link the .obj file. The link command doesn't link the .obj file to make an .exe but spews out all kinds of error messages and warnings. It seems, it craves more to justify time after time the caption of this thread.

Anyway...
thank you for all the effort you expended to impart/elevate some level of awareness to my otherwise rather shallow understanding.

Regards...

Vortex

Hi hell0,

Did you try to rebuild the code I posted?