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

Hi all,
I am a hobby programmer from India. Probably somebody from this forum might know me since I am a member of FreeBasic forum.
Now, I would like to wet my toe in MASM64 with my Windows 11. I have Visual Studio 2022 and I ran a test asm code successfully. But I would like to know how to run my asm file without the help of VS2022. Now the linker is complaining that it can't find the 'msvcrt.lib'
What I did ?
1. Write code in an .asm file and save it.
2. Run ml64.exe with this asm file and created .obj file.
3. Rum link.exe with this code - "link /SUBSYSTEM:CONSOLE /OUT:t1.exe t1.obj msvcrt.lib"

 

NoCforMe

Quote from: kcvinu on June 06, 2024, 07:03:03 AM3. Rum link.exe with this code - "link /SUBSYSTEM:CONSOLE /OUT:t1.exe t1.obj msvcrt.lib"
Dumb question, I know, but do you actually have msvcrt.lib?
Assembly language programming should be fun. That's why I do it.

zedd151

kcvinu, could you post your source code? There may be another way to do what you are trying to achieve.

I have asked that this thread be moved to the Campus...

StrykerX


TimoVJL

link needs library path for libraries.
with /LIBPATH:dir is possible to point folder for library
May the source be with you

kcvinu

Quote from: NoCforMe on June 06, 2024, 09:01:52 AM
Quote from: kcvinu on June 06, 2024, 07:03:03 AM3. Rum link.exe with this code - "link /SUBSYSTEM:CONSOLE /OUT:t1.exe t1.obj msvcrt.lib"
Dumb question, I know, but do you actually have msvcrt.lib?

Yes, I have that lib.

kcvinu

Quote from: sudoku on June 06, 2024, 10:14:02 AMkcvinu, could you post your source code? There may be another way to do what you are trying to achieve.

I have asked that this thread be moved to the Campus...
Sure. This is my code.
.code
main proc
    mov rax, 125
    ret
main endp

end

zedd151

#7
Quote from: kcvinu on June 06, 2024, 11:39:34 PMSure. This is my code.
.code
main proc
    mov rax, 125
    ret
main endp

end
if that is your entire code, you don't need msvcrt.lib for that.

Quote from: kcvinu on June 06, 2024, 11:38:27 PMYes, I have that lib.
what is the path to it, where is it located?

NoCforMe

Quote from: sudoku on June 06, 2024, 11:55:26 PM
Quote from: kcvinu on June 06, 2024, 11:39:34 PMSure. This is my code.
.code
main proc
    mov rax, 125
    ret
main endp

end
if that is your entire code, you don't need msvcrt.lib for that.
What he wrote.

Since you definitely do not need that library to assemble and link that code, just remove the reference to msvcrt.lib for now. Worry about that later ...

One thing, though: I believe you need to set the program's entry point. (You definitely need to do this for 32-bit code, and I assume the same for 64-bit code.)
.code
main proc
start:
    mov rax, 125
    ret
main endp

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

kcvinu

what is the path to it, where is it located?
[/quote]

That file resides more than one place
One location is this - C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.38.33130\lib\x64\msvcrt.lib

kcvinu

Quote from: NoCforMe on June 07, 2024, 02:03:56 AM
Quote from: sudoku on June 06, 2024, 11:55:26 PM
Quote from: kcvinu on June 06, 2024, 11:39:34 PMSure. This is my code.
.code
main proc
    mov rax, 125
    ret
main endp

end
if that is your entire code, you don't need msvcrt.lib for that.
What he wrote.

Since you definitely do not need that library to assemble and link that code, just remove the reference to msvcrt.lib for now. Worry about that later ...

One thing, though: I believe you need to set the program's entry point. (You definitely need to do this for 32-bit code, and I assume the same for 64-bit code.)
.code
main proc
start:
    mov rax, 125
    ret
main endp

end start

Thanks for the reply. Let me try that.

sinsi

Quote from: NoCforMe on June 07, 2024, 02:03:56 AM
Quote from: sudoku on June 06, 2024, 11:55:26 PM
Quote from: kcvinu on June 06, 2024, 11:39:34 PMSure. This is my code.
.code
main proc
    mov rax, 125
    ret
main endp

end
if that is your entire code, you don't need msvcrt.lib for that.
What he wrote.

Since you definitely do not need that library to assemble and link that code, just remove the reference to msvcrt.lib for now. Worry about that later ...

One thing, though: I believe you need to set the program's entry point. (You definitely need to do this for 32-bit code, and I assume the same for 64-bit code.)
.code
main proc
start:
    mov rax, 125
    ret
main endp

end start

In 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

zedd151

Quote from: sinsi on June 07, 2024, 02:36:32 AMIn 64-bit code, using ML64, end start will actually throw an error.
Quite right. Plus you need to tell link.exe the entry point that you are using example
  /ENTRY:<label_name> if different than the "C" default entry point (WinMainCRTStartup or whatever it is, I cannot remember offhand), else link will give an error message indicating the entry point cannot be found.

In your link switches for your example code posted above, add "/ENTRY:main"...

NoCforMe

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.)
Assembly language programming should be fun. That's why I do it.

kcvinu

Quote from: sudoku on June 07, 2024, 02:41:41 AMIn your link switches for your example code posted above, add "/ENTRY:main"...


Thanks. Let me try.