Debian Codegraph @

test cases/nasm/1 configure file/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 SECTION .data ; data section
11 msg: db "Hello World",10 ; the string to print, 10=cr
12 len: equ $-msg ; "$" means "here"
13 ; len is a value, not an address
14
15 SECTION .text ; code section
16 global main ; make label available to linker
17 main: ; standard gcc entry point
18
19 mov edx,len ; arg3, length of string to print
20 mov ecx,msg ; arg2, pointer to string
21 mov ebx,1 ; arg1, where to write, screen
22 mov eax,4 ; write sysout command to int 80 hex
23 int 0x80 ; interrupt 80 hex, call kernel
24
25 mov ebx,HELLO ; exit code, 0=normal
26 mov eax,1 ; exit command to kernel
27 int 0x80 ; interrupt 80 hex, call kernel