News:

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

Main Menu

How to use the 'echo' command in MASM

Started by megavlad, May 04, 2025, 09:11:00 AM

Previous topic - Next topic

megavlad

I'm using MASM in MSVC 2022, Windows 10. I'm coding in 64bit mode, only.

I'm learning from an assembly book that uses MASM. In there, it mentions the 'echo' command can be used to output compile-time messages. I tried adding it to my sample code, but I don't see the message in the MSVC output window.

I don't get an error, just nothing gets printed.

Is there something that needs to be enabled to support it?

Thanks

NoCforMe

echo is used in batch files. You know, the command files that are run from the Windows (or DOS if you're going back that far) command window. It displays to the command window:

@echo off

ml /c /coff /Fl /Sn %1.asm
if errorlevel 1 goto errasm

link /SUBSYSTEM:WINDOWS %1
if errorlevel 1 goto errlink

dir %1.*
goto TheEnd

:errlink
echo _
echo Link error
goto TheEnd

:errasm
echo _
echo Assembly Error

:TheEnd

It has nothing to do with assembly-langauge code.
32-bit code and Windows 7 foreva!

megavlad


NoCforMe

Whoops, my bad. Forgot about that echo.

You say you're using Visual C, right? It must have something to do with how that IDE handles output from the assembler. You might have to set a switch or something.

Someone who knows more about this than I do should be along shortly to help you ...
32-bit code and Windows 7 foreva!

Quin

Definitely a problem with msvc...
This works flawlessly with QEditor and the MASM32 SDK.
.386
.model flat, stdcall
option casemap: none

.code
start:
    echo This is a test
end start
I see
QuoteThis is a test
right after the
QuoteAssembling: C:\Users\Quin\git\test.asm
line.

megavlad

Quote from: Quin on May 04, 2025, 09:34:22 PM.386
.model flat, stdcall

Thanks for checking the 32bit version. Are you able to check if the 64bit version also works?

Quin


megavlad

Quote from: Quin on May 05, 2025, 12:49:40 AMYup, works in 64-bit, too. :)

Cool. If you don't mind, can you please show the exact snipped that you used for testing?

ChatGPT says that it's not supported in 64bit, but ChatGPT often lies.
Since you got it to work, I would use your test as working base, and fiddle with the IDE settings.

Thanks

zedd

Quote from: megavlad on May 05, 2025, 01:12:18 AMChatGPT says that it's not supported in 64bit, but ChatGPT often lies.
The results from ChatGPT or any other AI must always be tested and/or verified. I have learned that very early on in my experimentation using AI for assembly code, as well as C code.
:cool:

zedd

Quote from: megavlad on May 05, 2025, 01:12:18 AM
Quote from: Quin on May 05, 2025, 12:49:40 AMYup, works in 64-bit, too. :)

Cool. If you don't mind, can you please show the exact snipped that you used for testing?
I was curious, so I tested it myself: Nevermind what ChatGPT says regarding this... :biggrin:


yurp, it werks!

The code I used...
include \masm64\include64\masm64rt.inc

.data

.code

start proc

    echo Testing 1, 2, 3...
    invoke ExitProcess, 0
   
start endp

end

Batch file to assemble and link:
@echo off
SET asm="test64"
if exist %asm%.exe del %asm%.exe

\masm64\bin64\ml64 /c /nologo %asm%.asm
if errorlevel 1 goto paws

\masm64\bin64\Link /subsystem:windows /entry:start /nologo %asm%.obj
if errorlevel 1 goto paws

del *.obj

pause

Since I do not use Visual Studio or other "Visual" IDE, I viewed the command prompt output...
:cool:

Quin

You're faster than me Zedd :D
I step away to brew my coffee and you've answered a question someone had for me. Wizard!  :biggrin:

zedd

Quote from: Quin on May 05, 2025, 01:58:20 AMYou're faster than me Zedd :D
I step away to brew my coffee and you've answered a question someone had for me. Wizard!  :biggrin:
Actually I hate writing in 64 bit. But I was also curious as well, so I tested it.

Yes there is an echo in here.  :eusa_dance:
I am hardly a wizard though.  :cool:
:cool:

megavlad

Quote from: zedd on May 05, 2025, 01:28:59 AMSince I do not use Visual Studio or other "Visual" IDE, I viewed the command prompt output...

Thanks for verifying. I tried your example from the command line as well, and indeed it prints the message. Since that is a compile-time directive, the test can be reduced further to:

In assembly test file "test.asm":

echo Testing 1, 2, 3...
end


In command line:

ml64 /c test.asm




zedd

Quote from: megavlad on May 05, 2025, 02:36:02 AMSince that is a compile-time directive, the test can be reduced further to:
Of course you are correct. I was using a ready-made template (as-is) for testing.
:cool:

NoCforMe

Quote from: megavlad on May 05, 2025, 02:36:02 AM
Quote from: zedd on May 05, 2025, 01:28:59 AMSince I do not use Visual Studio or other "Visual" IDE, I viewed the command prompt output...

Thanks for verifying. I tried your example from the command line as well, and indeed it prints the message. Since that is a compile-time directive, the test can be reduced further to:

In assembly test file "test.asm":

echo Testing 1, 2, 3...
end

In command line:

ml64 /c test.asm

So were you able to solve your MSVC problem?
That would be useful info for others who use that IDE.
32-bit code and Windows 7 foreva!