The Console

Assembly language programs would be fairly boring if there were no way to get data in and out of the program from the user. Whilst we could write an entire Windows program for this purpose, making use of the various Graphical User Interface (GUI) elements that Windows provides, it turns out there is an easier way to interact with the user. This is by means of a console.

A console looks somewhat like a DOS box, and allows for capturing input from the keyboard and mouse and for outputting text on the screen. The operating system provides this service to us, and fortunately it is easy to make use of with very little knowledge of the Win32 API.

Of course calling Win32 API functions is not true asembly language programming, in that we are not calling hardware level functions. However, the latter are quite complicated and so we settle for telling the operating system what we want to do.

top

Opening a Console

Opening a console is easy. We simply invoke the Win32 API function called AllocConsole. It takes no parameters. The simplest program for doing this is as follows.

include '%fasminc%/win32ax.inc'

.code

  start:
        invoke  AllocConsole
        invoke  ExitProcess,0

.end start 

Needless to say, this program doesn't do very much. It merely opens a console and immediately exits, without even waiting for a keypress. In the following sections we describe how to use the console to interact with the user.