WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Sponsors
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
Hard Drive Recovery
Wiring your own LAN
Personal menu
Welcome Guest
User:
Pass:
Register!
Resend Validation Email
 
Forum
 

Problem running "Hello World" assembler program, Compiled as 32-bit Console application

xfactor973
Quote Post


New Member
*

Group: Members
Posts: 1
Member No.: 524
Joined: 12-September 04


I'm trying to get my "Hello World" program to run.
It compiles ok into an .EXE, but when i run it from the console, nothing happens.

CODE

comment * «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

                        Build this example with

                     >> Console Assemble & Link <<

; ««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««« *

   .486
   .model flat, stdcall
   option casemap :none  ; case sensitive

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

   include c:\masm32\include\windows.inc
   include c:\masm32\include\masm32.inc
   include c:\masm32\include\kernel32.inc
   include c:\masm32\macros\macros.asm

   includelib c:\masm32\lib\masm32.lib
   includelib c:\masm32\lib\kernel32.lib

   .code

start:

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

   print "Hello world"

   exit

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

end start


Is this correct?

I've never tried assembly before, and I come from a strong java background, so this is all very new to me.

Thanks.

PMEmail Poster
Top
n7yap
Quote Post


Active Member
***

Group: Members
Posts: 51
Member No.: 87
Joined: 10-June 04


The MASM32 print macro requires the address of a zero-terminated string like this:

CODE
print SADD("Hello World")


SADD is a macro that returns the address of the string.

If you're just starting out with MASM32, try writing your program without macros. You will learn more that way.

CODE
.DATA

 szHello  BYTE  "Hello world", 0

.CODE

start:

 invoke StdOut, ADDR szHello

 invoke ExitProcess, 0

end start
PMEmail Poster
Top
shoorick
Quote Post


Extremely Active Member
******

Group: Admins
Posts: 2301
Member No.: 160
Joined: 22-June 04


No, of course not!

Try this instead:
CODE
.DATA
hello   db "Hello World",0

.CODE

invoke MessageBox,0,ADDR hello,0,0
invoke ExitProcess,0


If you never used assembler before, first take a look at the examples, or create a project from the WinASm studio templates and play with it...

All languages have their specifications... wink.gif

Good luck!
PMEmail PosterUsers Website
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Reply to this topicStart new topicStart Poll

 

Sponsors
Computer Science

Internet
C/C++
Hardware & PC maintenance

HiEditor

General Discussions
Suggestions/Bug Reports
WinAsm Studio

General Discussions
Suggestions/Bug Reports
WinAsm Studio FAQ
Multilingual User Interface
Add-Ins
Assembly Programming

Main
Newbies
Projects
Custom Controls
Snippets
Announcements & Rules

Announcements

General

Online Degrees - Distance Learning
The Heap
Russian
Google