Author | ASM Hello World |
psyl0cke Member

Posts: 824 Location: sharing love everywhere ♥
Joined: 01.07.13 Rank: God | |
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.
Edited by psyl0cke on 01-08-16 12:30 |
 |
Author | RE: ASM Hello World |
Huitzilopochtli Member

Posts: 1644 Location:
Joined: 19.02.13 Rank: God | |
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? |
 |
Author | RE: ASM Hello World |
psyl0cke Member

Posts: 824 Location: sharing love everywhere ♥
Joined: 01.07.13 Rank: God | |
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
|
 |
Author | RE: ASM Hello World |
SuQuay_FuQuay Member

Posts: 20 Location:
Joined: 13.03.16 Rank: Hacker Level 2 | |
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. |
 |
Author | RE: ASM Hello World |
psyl0cke Member

Posts: 824 Location: sharing love everywhere ♥
Joined: 01.07.13 Rank: God | |
May you share the up-to-date code with us?
|
 |
Author | RE: ASM Hello World |
Lord_Zeyn Member

Posts: 7 Location: /home
Joined: 05.08.16 Rank: Active User | |
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. |
 |
Author | RE: ASM Hello World |
psyl0cke Member

Posts: 824 Location: sharing love everywhere ♥
Joined: 01.07.13 Rank: God | |
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"
Edited by psyl0cke on 06-08-16 12:41 |
 |
Author | RE: ASM Hello World |
_spartax_ Member

Posts: 33 Location: SYSTEM
Joined: 03.06.16 Rank: HBH Guru | |
@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 |
 |
Author | RE: ASM Hello World |
psyl0cke Member

Posts: 824 Location: sharing love everywhere ♥
Joined: 01.07.13 Rank: God | |
Do you know how to do it with NASM?
|
 |
Author | RE: ASM Hello World |
_spartax_ Member

Posts: 33 Location: SYSTEM
Joined: 03.06.16 Rank: HBH Guru | |
; 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 x = 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 |
 |
Author | RE: ASM Hello World |
_spartax_ Member

Posts: 33 Location: SYSTEM
Joined: 03.06.16 Rank: HBH Guru | |
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 |
 |
Author | RE: ASM Hello World |
psyl0cke Member

Posts: 824 Location: sharing love everywhere ♥
Joined: 01.07.13 Rank: God | |
How to the a Hello World with popup and console in 32bit and 64bit windows?
|
 |
Author | RE: ASM Hello World |
_spartax_ Member

Posts: 33 Location: SYSTEM
Joined: 03.06.16 Rank: HBH Guru | |
hii psyl0cke see http://paste.ubuntu.com/22836222/ |
 |
Author | RE: ASM Hello World |
psyl0cke Member

Posts: 824 Location: sharing love everywhere ♥
Joined: 01.07.13 Rank: God | |
How should I compile it under windows?
How to do it with console?
How to do it with 64bit console and popup?
|
 |
Author | RE: ASM Hello World |
psyl0cke Member

Posts: 824 Location: sharing love everywhere ♥
Joined: 01.07.13 Rank: God | |
_spartax_ wrote:
hii psyl0cke see http://paste.ubuntu.com/22836222/
asm_spartax_popup.asm:9: error: symbol `strMsg' undefined
|
 |
Author | RE: ASM Hello World |
psyl0cke Member

Posts: 824 Location: sharing love everywhere ♥
Joined: 01.07.13 Rank: God | |
Thanks for _spartax_ for the right code:
http://paste.ubuntu.com/22839587/ 
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.
|
 |
Author | RE: ASM Hello World |
psyl0cke Member

Posts: 824 Location: sharing love everywhere ♥
Joined: 01.07.13 Rank: God | |
This is the console version: http://pastebin.com/dbcrMUaq
|
 |
Author | RE: ASM Hello World |
psyl0cke Member

Posts: 824 Location: sharing love everywhere ♥
Joined: 01.07.13 Rank: God | |
How to write Hello World! in window, like on app10?
Edited by psyl0cke on 10-08-16 10:44 |
 |
Author | RE: ASM Hello World |
psyl0cke Member

Posts: 824 Location: sharing love everywhere ♥
Joined: 01.07.13 Rank: God | |
How to make this program work?
http://pastebin.com/XyP8GaqQ
|
 |
Author | RE: ASM Hello World |
psyl0cke Member

Posts: 824 Location: sharing love everywhere ♥
Joined: 01.07.13 Rank: God | |
It works now: http://psyl0ckediary.tumblr.com/post/148749366843/iv-hello-world-linux-win-printf-puts
|
 |