//-----------------------------------------------------------------
//	method1.s
//
//	This is one part of a two-piece suite which we've quickly 
//	written in order to compare the speed of invoking a Linux
// 	system-call using the new 'syscall' instruction versus an
//	older 'int $0x80' invocation.  Use these commands to find
//	out what advantage 'syscall' offers on your platform:  
//
//			$ time ./method1
//			$ time ./method2
//
//	programmer: ALLAN CRUSE
//	written on: 22 APR 2009
//-----------------------------------------------------------------


	.equ	sys_write, 4
	.equ	sys_exit, 1
	.equ	STDOUT, 1
	.equ	N_REPS, 80000


	.section	.data
msg:	.ascii	" Hello! "
len:	.quad	. - msg


	.section	.text
_start:
	mov	$N_REPS, %r10
nxmsg:
	# write hello message
	push	%r10
	mov	$sys_write, %rax
	mov	$STDOUT, %rbx
	lea	msg, %rcx
	mov	len, %rdx
	int	$0x80
	pop	%r10

	dec	%r10
	jnz	nxmsg
	
	# terminate program
	mov	$sys_exit, %rax
	mov	$0, %rbx
	int	$0x80

	.global	_start
	.end