Author Topic: Hello world  (Read 24353 times)

hghesteemed

  • Guest
Hello world
« on: September 19, 2012, 05:04:19 AM »
Hi,

I installed the masm32 and im following a simple tutorial to get hello world working and i can't get any output from the program. What is wrong with the code? Please help. Thanks

.386
.model flat, stdcall
option casemap :none
includeincludeinclude\masm32\include\windows.inc
\masm32\include\kernel32.inc
\masm32\include\masm32.inc
includelibincludelib\masm32\lib\kernel32.lib
\masm32\lib\masm32.lib
.data
HelloWorld db "Hello World!", 0
.code
start:
invoke StdOut, addr HelloWorld
invoke ExitProcess, 0
end start


It assembles and links ok but no output.

Vortex

  • Member
  • *****
  • Posts: 1987
Re: Hello world
« Reply #1 on: September 19, 2012, 05:09:22 AM »
Hi hghesteemed,

Welcome to the forum.

Did you build your project as CONSOLE application?

Code: [Select]
\masm32\bin\link /SUBSYSTEM:CONSOLE hello.obj
Don't forget to run your application from the command-line prompt.

hghesteemed

  • Guest
Re: Hello world
« Reply #2 on: September 19, 2012, 05:16:40 AM »
Hi

Yes its a console application, i use the gui to assemble and link, it seems to since I can see both my object code and executable. Just no output when I run.


Vozzie

  • Guest
Re: Hello world
« Reply #3 on: September 19, 2012, 05:21:32 AM »
Hi

Try the "inkey" macro...

Code: [Select]

include \masm32\include\masm32rt.inc

.data
HelloWorld db "Hello World!",13,10,0
.code
start:
invoke StdOut, addr HelloWorld
inkey "Press a key to continue ..."


invoke ExitProcess, 0
end start

(also more easy to use the masm runtime include)

Greetings

dedndave

  • Member
  • *****
  • Posts: 8823
  • Still using Abacus 2.0
    • DednDave
Re: Hello world
« Reply #4 on: September 19, 2012, 08:37:03 AM »
i am a bit surprised it assembles with all this...
Code: [Select]
includeincludeinclude\masm32\include\windows.inc
\masm32\include\kernel32.inc
\masm32\include\masm32.inc
includelibincludelib\masm32\lib\kernel32.lib
\masm32\lib\masm32.lib

at any rate, we have a little shortcut
you can look inside the \masm32\include\masm32rt.inc file with a text editor to see what it does

Code: [Select]
include \masm32\include\masm32rt.inc
.data
HelloWorld db "Hello World!", 0
.code
start:
invoke StdOut, addr HelloWorld
inkey
invoke ExitProcess, 0
end start

Gunther

  • Member
  • *****
  • Posts: 3585
  • Forgive your enemies, but never forget their names
Re: Hello world
« Reply #5 on: September 20, 2012, 01:58:05 AM »
Hi hghesteemed,

welcome to the forum.

Gunther
Get your facts first, and then you can distort them.

kroz

  • Guest
Re: Hello world
« Reply #6 on: September 21, 2012, 11:29:59 AM »
for a messagebox :

type in .CODE section :

invoke MessageBox, NULL, offset msg, offset cap, MB_OK
invoke ExitProcess, eax

type in .DATA section :

msg db "Hello World ", 0
cap db "Hey There! ",0

hope this helpss

Vortex

  • Member
  • *****
  • Posts: 1987
Re: Hello world
« Reply #7 on: September 22, 2012, 03:04:30 AM »
Hi kroz,

In addition :

Code: [Select]
\masm32\bin\link /SUBSYSTEM:WINDOWS ...