• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; nasm -f elf hello.asm		# this will produce hello.o ELF object file
2; ld -s -o hello hello.o	# this will produce hello executable
3
4section	.text
5    global _start			;must be declared for linker (ld)
6
7_start:					;tell linker entry point
8
9	mov	edx,len	;message length
10	mov	ecx,msg	;message to write
11	mov	ebx,1	;file descriptor (stdout)
12	mov	eax,4	;system call number (sys_write)
13	int	0x80	;call kernel
14
15	mov	eax,1	;system call number (sys_exit)
16	int	0x80	;call kernel
17
18section	.data
19
20msg	db	'Hello, world!',0xa	;our dear string
21len	equ	$ - msg			;length of our dear string
22
23