Desktop Projects
A Console Window in Microsoft Assembler
Iâve created this project around 2009, when I was learning Pentium machine language on Windows.
This is a MASM32 Windows application. It uses the Win32 and GDI Windows Libraries to display a little terminal window, that is a full-fledged GUI application rather than a command line app.
It was published on a now defunct website called âCodeProjectâ, a precursor to GitHub.
I couldnât find the write-up I did for the article yet, so for now, I am only providing a link to a PDF I saved at some point.
See also this thread in the Masm32 forum.
Although what I wrote then makes me smile, what the source code does show is how nicely structured you can actually program in a modern macro assembler.
Iâm not kidding, itâs not that bad compared to C++. This was particularly true back then, when WinTel (Windows + Intel) was very much an inseparable thing, so you would not have profited from portability to other architectures anyway. It was not even on the horizon for them.
The library calls are arguably much clearer, since you can literally see what/how the parameters are passed on the stack or â as in this case â using cpu registers.
;invalidate the bottom line region of the client bitmap
;so that it will be repaintedby the WM_PAINT message handler
repaint_line proc
mov edx, paddedClientWidth
mov Rectx, 0
mov Recty, bottomLine
mov Rectw, edx
mov Recth, lineHeight
invoke InvalidateRect, ;this is to show Windows that the marked
hWnd, ;region has changed and needs repainting
Rectx,
FALSE
invoke UpdateWindow, hWnd ;repaint the updated region
ret
repaint_line endp
Masm32 had (has?) a very interesting licensing structure. At the time, the group around the MASM32 forum had special, official permission from Microsoft to distribute the assembler! Donât quote me on this though. There is a 64-bit version of Masm which I havenât explored.
Downloads
The download section has the full source-code repo, including a Windows DLL that turns the console into a reusable component. You can load the DLL in a C or C++ program, and write text into the window, and get text back from it using a call-back function when the user hits return.
The nice thing about using the DLL is that you donât need to know anything about GDI/GUI programming on Windows, in order to add a little console window to your programs.