Welcome to HBH V2 ! If you had an account on hellboundhacker.org you will need to reset your password using the Lost Password system before you will be able to login.

ASM Hello World


psyl0cke's Avatar
Member
0 0

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.


Huitzilopochtli's Avatar
....
0 5

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?


psyl0cke's Avatar
Member
0 0

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


SuQuay_FuQuay's Avatar
Member
0 0

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.


psyl0cke's Avatar
Member
0 0

May you share the up-to-date code with us?


Lord_Zeyn's Avatar
Member
0 0

Hey psyl0cke, this is the example of "Hello world" program in NASM (Netwide Assembler):

http://pastebin.com/Kqwp6Fse

However, you need to have fundamental knowledge of working principles of CPU and memory to better understand this code.


psyl0cke's Avatar
Member
0 0

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"


_spartax_'s Avatar
Member
0 0

@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


psyl0cke's Avatar
Member
0 0

Do you know how to do it with NASM?


_spartax_'s Avatar
Member
0 0

; 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


_spartax_'s Avatar
Member
0 0

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


psyl0cke's Avatar
Member
0 0

How to the a Hello World with popup and console in 32bit and 64bit windows?


psyl0cke's Avatar
Member
0 0

How should I compile it under windows? How to do it with console? How to do it with 64bit console and popup?


psyl0cke's Avatar
Member
0 0

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.


psyl0cke's Avatar
Member
0 0

How to write Hello World! in window, like on app10?