ASM Hello World
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.
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
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.
@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
; 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
hii psyl0cke see http://paste.ubuntu.com/22836222/
spartax wrote: hii psyl0cke see http://paste.ubuntu.com/22836222/
asm_spartax_popup.asm:9: error: symbol `strMsg' undefined
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.
This is the console version: http://pastebin.com/dbcrMUaq
How to make this program work? http://pastebin.com/XyP8GaqQ