Outputting Hello World in MASM using WIN32 Functions

自闭症网瘾萝莉.ら 提交于 2019-12-01 05:40:35
Madhur Ahuja

The program is fine. It is indeed "Hello World" version of Win32. However, remember its a console program. In Win32, you will be mostly dealing with Windows, Dialog Boxes and very less with Console (Incase, you want to deal specifically with console, thats another story).

If you want to lean Win32 Assembly, I strongly suggest you to look at Iczelion Tutorials.

Here is the "Hello World" to start with his tutorials:

http://win32assembly.online.fr/tut2.html

This sample code is simpler and easy to understand

.386
.model flat, stdcall
option casemap: none

include windows.inc
include user32.inc
include kernel32.inc
includelib user32.lib
includelib kernel32.lib

.data
    szCaption   db  'Hello', 0
    szText      db  'Hello, World!', 0

.code
    start:
            invoke MessageBox, NULL, offset szText, offset szCaption, MB_OK
            invoke ExitProcess, NULL        
    end start

StdOut is a console function

You can use MessageBox function...

.model small,pascal,nearstack
.386
?WINPROLOGUE=1
include win.inc
includelib libw.lib
extern __astart:proc

.data
text sbyte "Hello f*** World!",0
title sbyte "Win",0

.code
WinMain    PROC, hInstance:HANDLE, hPrevInstance:HANDLE, lpszCmdLine:LPSTR, nCmdShow,WORD
  LOCAL msg:MSG

 invoke MessageBox, NULL, addr text, addr title, 0
 invoke PostQuitMessage,0

 .while TRUE
     invoke GetMessage,addr msg,NULL,0,0
     .break .if (ax == 0)
     invoke TranslateMessage,addr msg
     invoke DispatchMessage,addr msg
 .endw
WinMain    ENDP
END        __astart
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!