Text is the simplest to do, because it is in ASCII form and the output devices like the monitor and printer are expecting it in ASCII. As in C, Windows is expecting text to be null terminated.
There are two procedures (sub-programs) that we will look at. They are named StdOut and StdIn.
; ######################################################################### .386 .model flat, stdcall option casemap :none ; case sensitive ; ######################################################################### include \masm32\include\windows.inc include \masm32\include\user32.inc include \masm32\include\kernel32.inc include \masm32\include\masm32.inc includelib \masm32\lib\user32.lib includelib \masm32\lib\kernel32.lib includelib \masm32\lib\masm32.lib ; ######################################################################### ; ------------ ; Local macros ; ------------ print MACRO Quoted_Text:VARARG LOCAL Txt .data Txt db Quoted_Text,0 .code invoke StdOut,ADDR Txt ENDM .data ; ------------ ;StdOut requires that the data to be output is in the .data section of the program. ; ------------ ary db "My Message",0 txt db ?, 0 .code start: ; ------------ ;Start by printing out a single character and move cursor to the next line. ; ------------ mov al, 'A' mov txt, al invoke StdOut,ADDR txt print 10,13 ; ------------ ;Now print out the array one character at a time. ; ------------ mov ecx, 10 ;There are ten characters in the array. mov esi, offset ary ;Point to the beginning of the array prntAry: mov al, [esi] ;Get next character. mov txt, al ;Save it in the output buffer. ; ------------ ;I don't know what registers StdOut uses, so I will save my essential registers. ; ------------ push ecx push esi invoke StdOut,ADDR txt ;Now do the output ; ------------ ;Restore my essential registers. ; ------------ pop esi pop ecx inc esi ;Point to the next character in the array loop prntAry ;The loop instruction decrements ECX and if not ; zero loop back up. print 10,13 ;Move cursor to the next line. invoke ExitProcess,0 ;We are done. end start