News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

New member here, need some guidance to start

Started by kcvinu, June 06, 2024, 07:03:03 AM

Previous topic - Next topic

kcvinu


zedd151

#16
I have made you a small example based on your code.

include \masm64\include64\masm64rt.inc

.code
main proc
    mov rax, 125
    invoke MessageBox, 0, str$(rax), 0, 0
    invoke ExitProcess, 0
    ret
main endp

end
Run the program, a MessageBox will pop up with a string of the value in rax. Then the program will exit gracefully using ExitProcess.

and a batch file to assemble and link it
\masm64\bin64\ml64.exe /c test.asm

\masm64\bin64\link.exe /SUBSYSTEM:WINDOWS /ENTRY:main test.obj

pause

Ventanas diez es el mejor.  :azn:

kcvinu

Quote from: sudoku on June 07, 2024, 03:03:02 AMI assume that you have the masm64 SDK installed??


Unfortunately, that's the important thing I missed. Where can I download masm64 SDK ?

EDIT: Ah, I got from this site. Which is the best place to paste the "masm64" folder ? Do I need to set in PATH ?

NoCforMe

The standard thing to do is to put it (the whole MASM64 package) as the first subdirectory of whatever drive you want to use, like E:\masm64\ .... That way you can share code here with other members and have it work on their setups without having to modify anything. (Don't include the drive letter in your batch file! Your stuff should be drive-agnostic.)

I set my PATH to the folder with the executables (ML.exe, link.exe, etc.), but other folks here frown on that for some reason. So if you don't set the path you'll need to explicitly put the path in either your command line or your batch file. (Please tell us you're going to use a batch file, rather than having to type in all that stuff each and every time!)

BTW, question for regulars here: is this stuff (basic MASMxx setup) explained anywhere here? clearly? in a place that's not hidden, like a "readme" file stuck somewhere where nobody's going to look at it?

Assembly language programming should be fun. That's why I do it.

sinsi

Quote from: NoCforMe on June 07, 2024, 02:59:05 AM
Quote from: sinsi on June 07, 2024, 02:36:32 AMIn 64-bit code, using ML64, end start will actually throw an error.
Microsoft (R) Macro Assembler (x64) Version 14.40.33811.0
Copyright (C) Microsoft Corporation.  All rights reserved.

 Assembling: C:\masm32\crap.asm
C:\masm32\crap.asm(5) : error A2008:syntax error : start
C:\masm32\crap.asm(5) : error A2088:END directive required at end of file
But why the error for having start: there? Isn't it legal to have a label in your code? or is there something special about "start"?

(I do now understand that the setting-the-entry-point thing is different from 32-bit code.)
You notice the two errors are on line 5, which is end start.
What the error is saying is that it parsed the end ok but there's this start thing that shouldn't be there, since end doesn't take any parameters.
That's why the second error complains about no end, since the whole line was invalid.
Tá fuinneoga a haon déag níos fearr :biggrin:

NoCforMe

Assembly language programming should be fun. That's why I do it.

zedd151

Quote from: kcvinu on June 07, 2024, 03:20:57 AM
Quote from: sudoku on June 07, 2024, 03:03:02 AMI assume that you have the masm64 SDK installed??


Unfortunately, that's the important thing I missed. Where can I download masm64 SDK ?

EDIT: Ah, I got from this site. Which is the best place to paste the "masm64" folder ? Do I need to set in PATH ?
No just unzip it to the root of the drive where you will keep your projects.
You will then either have to copy ml64 and link (plus their associated dependencies) to \masm64\bin64 or change the paths in the batch file for ml64 and link.

I don't know the paths in Visual Studio otherwise I would have adjusted the batch file accordingly. You should not have to set any environment variables (I.e. PATH)

Other members here that work with both visual studio and Masm64 may be able to help you better than I could in some instances.

Let us know how it is going with your Masm64 SDK install.
Ventanas diez es el mejor.  :azn:

NoCforMe

Quote from: sudoku on June 07, 2024, 03:53:55 AMYou will then either have to copy ml64 and link (plus their associated dependencies) to \masm64\bin64 or change the paths in the batch file for ml64 and link.
Wait a sec: doesn't the MASM64 package come with a \bin folder with all the needed executables in it, like MASM32 does?
Assembly language programming should be fun. That's why I do it.

zedd151

Unfortunately there are bits and pieces in various threads, and no "One Stop" instructions for setting up Masm64 SDK. 
NoCforMe, no unfortunately hutch did not have permission to do that, due to licensing restrictions.
Ventanas diez es el mejor.  :azn:

NoCforMe

Quote from: sudoku on June 07, 2024, 04:15:44 AMUnfortunately there are bits and pieces in various threads, and no "One Stop" instructions for setting up Masm64 SDK.
Well, there oughta be, dontcha think?
Unless you want to keep fielding questions like this forever.

BTW, I'd be more than happy to edit such instructions for clarity. However, I'm not knowledgeable enough about MASM64 to actually write them.
Assembly language programming should be fun. That's why I do it.

zedd151

Quote from: NoCforMe on June 07, 2024, 04:17:19 AMHowever, I'm not knowledgeable enough about MASM64 to actually write them.
Me neither, but this should be a good starting point...

https://masm32.com/board/index.php?topic=12016.0

If anyone would like to add to or change any of that let it be known please.
NoCforMe, good idea.  :icon_idea:

Ventanas diez es el mejor.  :azn:

NoCforMe

Rather than continue to clutter this topic (sorry, OP!), I'll start a new discussion in the MASM64 sub-forum.

Done. (sudoku started it) Here it is.
Assembly language programming should be fun. That's why I do it.

TimoVJL

Just to remind:
/ENTRY (Entry-Point Symbol)

QuoteFunction name    Default for
mainCRTStartup (or wmainCRTStartup)    An application that uses /SUBSYSTEM:CONSOLE; calls main (or wmain)
WinMainCRTStartup (or wWinMainCRTStartup)    An application that uses /SUBSYSTEM:WINDOWS; calls WinMain (or wWinMain), which must be defined to use __stdcall
_DllMainCRTStartup    A DLL; calls DllMain if it exists, which must be defined to use __stdcall
May the source be with you

NoCforMe

Well, those are predefined names, right, Timo? Meaning you don't have to use them in an assembly-language program.

Timo, you are so C-centric:
QuoteBy default, the starting address is a function name from the C run-time library.

But we don't have to use that library.
Assembly language programming should be fun. That's why I do it.

zedd151

Quote from: NoCforMe on June 07, 2024, 04:53:49 AMBut we don't have to use that library.
Yes, and I suspect that is what led the OP to think that msvcrt.lib was needed.
Ventanas diez es el mejor.  :azn: