The MASM Forum

Miscellaneous => Irvine Book Questions. => Topic started by: dkosta on February 18, 2016, 12:16:36 AM

Title: Compile and link problems
Post by: dkosta on February 18, 2016, 12:16:36 AM
I'm trying to learn assembly language book Kip Irvine 5th edition, one of the examples I have is:

TITLE Suma y Resta
INCLUDE C:\Users\...\...\IrvineExamples\Irvine32.inc
.code
main PROC
    mov     eax,10000h
    add     eax,40000h
    sub     eax,20000h
    call      DumpRegs
    exit
main ENDP
END main

I joined with "ml /c /coff file.asm name" and get the name_file.obj, but when I use "link name_file.obj" get out: LINK: fatal error LNK1221: a subsystem can not be inferred and must be defined .
I do not understand the error, Could someone tell me I'm doing wrong ?, the example is written as it appears in e book.
P.D- Could not they put more verification questions? I remember having exams with fewer questions  :lol:
Title: Re: Compile and link problems
Post by: jj2007 on February 18, 2016, 12:54:58 AM
The linker needs the option /Subsystem:Console

Welcome to the forum :icon14:

Btw, if you are not brutally forced by some almighty teacher to use that book, consider studying the \Masm32\Examples folder instead (provided you installed Masm32 - here are step by step instructions (http://www.webalice.it/jj2006/Masm32_Tips_Tricks_and_Traps.htm))
Title: Re: Compile and link problems
Post by: dkosta on February 18, 2016, 04:56:51 AM
Thanks for the reply jj2007, but using /Subsystem:Console obtain new errors:
error LNK2001: unresolved external symbol _ExitProcess@4
error LNK2001: unresolved external symbol _DumpRegs@0
fatal error LNK1120: 2 unresolved external
I'm not a student, after learning C and C ++ (just curious) I incredably learn assembly language, use the book Kip Irvine because I found a good book, but it seems that you do not feel the same, what book would you recommend?
Title: Re: Compile and link problems
Post by: jj2007 on February 18, 2016, 05:08:54 AM
If you get linker errors, it means the assembly succeeded :t

Re good books, go to the link I posted above, scroll down to recommended reading and look for Randall Hyde.
Besides, go to http://masm32.com/board/index.php?topic=5096.msg54834#msg54834 and follow the instructions.

Here is a Hello World for checking your assembler & linker command lines:
include \masm32\include\masm32rt.inc ; plain Masm32 for the fans of pure assembler

.code
AppName db "Masm32:", 0

start: MsgBox 0, "Hello World", addr AppName, MB_OK
exit

end start
Title: Re: Compile and link problems
Post by: dkosta on February 18, 2016, 06:17:07 AM
Thank you. The code that I've written compiles perfectly and I get the executable, but the book's examples do not have the same fate. I'll take a look at the book by Randall Hyde, but I take some time because I do not speak English and is the only language in which I have found, but as they say, the higher the greater effort is satisfaction.
Title: Re: Compile and link problems
Post by: jj2007 on February 18, 2016, 06:24:23 AM
Randall's book for the theory, \Masm32\Examples\ for practicing. You can't go wrong with that combination ;-)

And we are here to answer questions.