A Useful String Macro

FASM provides a useful macro that saves us having to explicitly declare and initialise a string. Instead of providing a pointer to the variable which contains our string, we can just type in the string itself.

Thus the line that writes to the console becomes

invoke  WriteConsole,[outhandle],"Hello World!",12,numwritten,0

Of course the problem with defining a string this way is that we can only use it once. However, if this is not a problem, it is a useful time saving device for us. Of course internally, the macro just replaces the string with a pointer to a string which is then declared elsewhere without us seeing it.

top

Newline Character

Each call to WriteConsole simply writes to the screen immediately following the text just written. To go to a new line, we need to send a newline character to the console. This character has ASCII code 13, so we declare such a character as follows:

endline DB 13

To output this character to the console, we just output it as a one byte string, just as we would any other string:

invoke  WriteConsole,[outhandle],endline,1,numwritten,0