The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: runtimeTerror on February 02, 2005, 12:09:37 AM

Title: Hello World in ASM
Post by: runtimeTerror on February 02, 2005, 12:09:37 AM
Hi, just wondering, as with most languages, the first thing you learn is ow to write out "Hello World". I was wondering
if I could be pointed to some examples on this forum.

Just wanted to keep the first question an easy one.

Cheers, runtime.
Title: Re: Hello World in ASM
Post by: P1 on February 02, 2005, 12:15:40 AM
Welcome runtimeTerror,    :U

You will find some the best people in the world, come here to get answers, as well as give them.

If you like getting and giving help in Assembler, this is the place for you!!  :clap:

Look forward to you participating with us.   

Start with Downloading MASM32 package and start going through the helps, examples and tutorials there.

This will start you Quick!

Regards,  P1  :8)
Title: Re: Hello World in ASM
Post by: white scorpion on February 02, 2005, 06:37:19 AM
well everyone would point you to iczelion's tutorial which you can find here (http://win32asm.cjb.net/). This is the best tutorial around for masm so i would say give it a try :)

as for a simple hello world:


.386
.model small,stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

.DATA
AppName  db  "White Scorpion",0
Hello         db  "Hello World!",0

.CODE

start:

invoke MessageBox,NULL,addr Hello,addr AppName,MB_OK

invoke ExitProcess,0

end start



this code calls a messagebox as a simple hello world program.
Title: Re: Hello World in ASM
Post by: Nilrem on February 02, 2005, 12:00:40 PM

.386
.model small,stdcall
option casemap:none

include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
include \masm32\macros\macrso.asm

.DATA
Hello         db  "Hello World!",0

.CODE

start:

Routine Proc
   lpstring[128]:DWORD; For user input, see macros.asm

   invoke StdOut, ADDR Hello; Print the message to the screen
   mov lpstring, input (); Press enter and it quits.
   ret
endp



end start
Title: Re: Hello World in ASM
Post by: runtimeTerror on February 02, 2005, 03:31:07 PM
Thanks guys! Appreciate the help.
Title: Re: Hello World in ASM
Post by: hutch-- on February 03, 2005, 12:32:55 AM
hmmmmm,

How about simpler code again using macros.


    cls
    print "Hello World"

    exit


This is why MASM32 has a macro system so the hack stuff is easy to do and make learning assembler a lot simpler.
Title: Re: Hello World in ASM
Post by: tenkey on February 03, 2005, 01:22:07 AM
Otherwise, if you wanted to avoid MASM32 macros, it would look something like this...


; This works a lot better if it's created as a console application
;   (linker option /subsystem:console)

.386
.model small,stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

.DATA
Hello         db  "Hello World!",13,10
Hello_length  equ $-Hello

BytesWritten  dd 0

.CODE

start:

invoke GetStdHandle,STD_OUTPUT_HANDLE
invoke WriteFile,eax,ADDR Hello,Hello_length,ADDR BytesWritten,NULL

invoke ExitProcess,0

end start
Title: Re: Hello World in ASM
Post by: James Ladd on February 03, 2005, 06:12:22 AM
Personally I like "tenkey"'s example.