ASM Hello World
Uh oh. Looks like your using an ad blocker.
Our site is support by ads that help to pay our hosting costs. Please disable or whitelist us within your ad blocker to help us keep the site online.
All money generate by ads and donations is used to pay the hosting costs of the site, for more information about our income and expenses please see our donation page.
I started learning assembly, and I found a hello world example on the site. .MODEL small .DATA printme db \"Hello World!\",13,10,\'$\' .CODE mov ax,@data mov ds,ax mov dx,offset printme mov ah,9 int 21h mov ax,4c00h int 21h
I try 'nasm -f elf test.asm', but I catch error. May somebody show me the right code? I use windows which is 64 bit, but I run the 32bit compiler.
printme db \"Hello World!\",13,10,\'$\' Those back slashes are from php addslashes () and prob shouldn't be in your code.
Apart from that, what does the error message say?
hello.asm:1: error: attempt to define a local label before any non-local labels hello.asm:1: error: parser: instruction expected hello.asm:2: warning: label alone on a line without a colon might be in error hello.asm:2: error: attempt to define a local label before any non-local labels hello.asm:4: warning: label alone on a line without a colon might be in error hello.asm:7: error: comma, colon, decorator or end of line expected after operand
The errors are due to you using old 16 bit DOS code that probably won't work on modern versions of windows, unless you use an emulator like DOSbox.
The warnings can be ignored as the interpreter thinks those might be labels, thinks you may have mis-spelled something, so alerts you just incase.
May you share the up-to-date code with us?
Hey psyl0cke, this is the example of "Hello world" program in NASM (Netwide Assembler):
However, you need to have fundamental knowledge of working principles of CPU and memory to better understand this code.
How should I compile it? I can't get the .exe file. I know nasm.exe -fwin32 hello.asm What article series do you recommend? It says "hello.asm:2: warning: label alone on a line without a colon might be in error"
@psyl0cke, the code you have written, is in **MASM **specification. That is you have written code for **MASM **assembler (Macro Assembler) not NASM. So NASM doesn't compile it. Compile it with ml and link with link commands
Do you know how to do it with NASM?
; hello_world.asm ; compile with NASM ; nasm -f bin hello_world.asm -o hello_world.com
org 0x100 ; COM files start at 0x100
mov dx, msg mov ds, dx ; ds:dx = msg mov ah, 0x09 ; print string function in DOS int 0x21
; lets terminate the program mov ax, 0x4c00 ; ah = 0x4c (exit_function), al = 0x00 (return code) int 0x21 ret
msg db 'Hello World', 0x0D, 0x0A, '$' ; MS-DOS strings are '$' terminated
COM files are 16 bit. So they won't run on a 64-bit windows machine. They will run on a 32-bit windows machine. To work in 32-bit / 64-bit machines you must program either in Windows / Linux Assembly
How to the a Hello World with popup and console in 32bit and 64bit windows?
How should I compile it under windows? How to do it with console? How to do it with 64bit console and popup?
Thanks for spartax for the right code: http://paste.ubuntu.com/22839587/ :D
I compiled it by: nasm -f win32 hello_world_popup.asm -o hello_world_popup.obj I linked it by: GoLink.exe /console /entry _start hello_world_popup.obj kernel32.dll user32.dll
I'm looking for the console variant now.
How to write Hello World! in window, like on app10?