Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Dec 1999 22:19:17 -0200 (EDT)
From:      Carlos Antonio Ruggiero <toto@if.sc.usp.br>
To:        freebsd-questions@freebsd.org
Subject:   Re: Hello World in Assembler
Message-ID:  <199912030019.WAA22111@ultra3000.if.sc.usp.br>

next in thread | raw e-mail | index | archive | help
Just in case anyone is interested... The following program solves
the problem I posted (Hello World in assembly language without using C):

section	.data
msg	db "Hello World",0x0A
len	equ	$ - msg
	
section	.text

	global	_start
	
_start:	
	push	long len   ; 3rd parameter: length of string
	push	long msg   ; 2nd parameter: address of string
	push	long 1     ; 1st parameter: standard output
	push	long there ; return address
	mov	eax,4	   ; System call #4 (see /usr/include/sys/syscall.h)
	int	0x80	   ; call kernel
there:	mov	eax,1      ; System call #1 (SYS_exit)
	push	long	0
	int	0x80


It can be assembled and linked with nasm and ld:

nasm -f elf -o hello.o hello.asm
ld -o hello hello.o


Toto
toto@ifsc.sc.usp.br


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199912030019.WAA22111>