The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: marla on February 16, 2006, 04:19:24 PM

Title: print to screen?
Post by: marla on February 16, 2006, 04:19:24 PM
instead of using windows, i want to use a simple cmd.exe window - i want to just print to console, how can i do this?
Title: Re: print to screen?
Post by: PBrennick on February 16, 2006, 05:25:25 PM
marla,
When you build the project, link it in the following manner:

\masm32\bin\link /SUBSYSTEM:CONSOLE /RELEASE /VERSION:4.0 appname.obj

This will open a console window automaticaly and you can use any of the console commands, if you need an example, just ask.

Paul

Title: Re: print to screen?
Post by: marla on February 16, 2006, 05:44:47 PM
i need an example... thx again for the help
Title: Re: print to screen?
Post by: Tedd on February 16, 2006, 06:12:54 PM
code vomit..

.386
.model flat, stdcall
option casemap:none
include windows.inc
include kernel32.inc
includelib kernel32.lib

.data
greeting    db "Hello World!",0

.data?
hStdOut     HANDLE  ?
hStdErr     HANDLE  ?
chWritten   DWORD   ?

.code
start:
    invoke GetStdHandle, STD_OUTPUT_HANDLE
    mov hStdOut,eax
    invoke GetStdHandle, STD_ERROR_HANDLE
    mov hStdErr,eax

    invoke WriteFile, hStdOut,ADDR greeting,SIZEOF greeting-1,ADDR chWritten,NULL

    invoke ExitProcess, NULL

end start