News:

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

Main Menu

Creating a console window

Started by FJRusso53, July 24, 2024, 03:18:26 AM

Previous topic - Next topic

FJRusso53

I am using MASM32 in VS 2022.  My present project is in excess of 6k lines.  The project runs inside of VS2022 using the debugger.  Everything I want it to do works.  My problem is if I try to run the executable it doesn't.  I get a console window with a line of text lasting for 3-5 seconds then the window disappears.  I am running on a desktop w/Win10. 

Thoughts?


zedd151

Could you post the source code? Would make helping you much easier.
:azn:

NoCforMe

Sorry to ask (like asking the lady who called tech support "is it plugged in?", but are you trying to run your program from a command window or from Explorer, like you'd do for a GUI program? If the latter, then what you wrote is the expected behavior: it opens a command window, runs the program, then closes the window.
Assembly language programming should be fun. That's why I do it.

Greenhorn

If you start a console application in VS, it keeps the console window open after the program has finished("Please press a key to continue" or so).
And if you execute the program outside of VS, and you do not call the function system("pause") or getchar() your console window will close immediately after the program has finished.
Kole Feut un Nordenwind gift en krusen Büdel un en lütten Pint.

TimoVJL

This might helpWindows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Classes\*\shell\Open With cmd\command]
@="\"cmd.exe\" \"/k \"%1\"\""
After that, right click file and choose Open With cmd
May the source be with you

Vortex

Hi FJRusso53,

The function wait_key can do the job for you, it expects keyboard input from the user and this can be useful to keep open the console window :

include     \masm32\include\masm32rt.inc

.data

message     db 'This is a wait_key test.',13,10
            db 'Press any key to exit.',0

.code

start:

    invoke  StdOut,ADDR message

    invoke  wait_key

    invoke  ExitProcess,0

END start

FJRusso53

Once I identified where in the app an abort seem to be occurring I was actually able to id the line of code where the failure occurred.  It resided with a 'repnz scabs' statement. Took a little thought and backtracking to realize what was going on.  This section of code was processing data read into a buffer.  SO, something had to be wrong with the buffer when I executed the exe.  Long story short, the files my code wanted to read are in the same directory as the vs source but the exe file is not.  Put the exe in the same folder and everything works.  I added the full file path to the file names and again all is good.

NoCforMe

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