How to write to the console in fasm?

codinggoose picture codinggoose · Mar 29, 2010 · Viewed 9.5k times · Source

I'm exceptionally new to assembly. I only picked it up yesterday and I've looked through many examples and still can't figure out for myself how to write to the console. I always get an error when I seem to replicate it in my own way.

Answer

Jens Björnhager picture Jens Björnhager · Apr 2, 2010

Use WriteConsole.

include 'win32wxp.inc'

.code
  start:
        invoke  AllocConsole
        invoke  WriteConsole,<invoke GetStdHandle,STD_OUTPUT_HANDLE>,tex,12,dummy,0
        invoke  Sleep,-1
.end start

.data
tex     TCHAR   'Hello World!'
dummy   rd      1