Debian Codegraph @

test cases/nasm/2 asm language/hello-x86.asm

raw
1 ; hello.asm a first program for nasm for Linux, Intel, gcc
2 ;
3 ; assemble: nasm -f elf -l hello.lst hello.asm
4 ; link: gcc -o hello hello.o
5 ; run: hello
6 ; output is: Hello World
7
8 %include "config.asm"
9
10 %ifdef FOO
11 %define RETVAL HELLO
12 %endif
13
14 SECTION .data ; data section
15 msg: db "Hello World",10 ; the string to print, 10=cr
16 len: equ $-msg ; "$" means "here"
17 ; len is a value, not an address
18
19 SECTION .text ; code section
20 global main ; make label available to linker
21 main: ; standard gcc entry point
22
23 mov edx,len ; arg3, length of string to print
24 mov ecx,msg ; arg2, pointer to string
25 mov ebx,1 ; arg1, where to write, screen
26 mov eax,4 ; write sysout command to int 80 hex
27 int 0x80 ; interrupt 80 hex, call kernel
28
29 mov ebx,RETVAL ; exit code, 0=normal
30 mov eax,1 ; exit command to kernel
31 int 0x80 ; interrupt 80 hex, call kernel