/*  This assembly language program does a system call.  You see it ALL here -
 *  no libraries, no hidden code.  We go straight from this program to
 *  the operating system.
 *
 *  The system call is a Linux write call.  According to the man page, 
 *  this call has a format:
 *      ssize_t write(int fd, const void *buf, size_t count);
 *
 *  Compile as follows:
 *      gcc SystemCallExample.s -o SystemCallExample
 */
.data
hello:
	.string "hello world\n"

.globl	main
        
main:
    //  The number 4 represents the system call number SYS_write */
	movl	$4,%eax
    //  The fd used here is SYSOUT and has a value of 1  
	movl	$1,%ebx
    //  We load the address of the output buffer
	movl	$hello,%ecx
    //  The number of bytes we want to write
	movl	$12,%edx
    //  OK - now we're ready for ACTION!  The next command is
    //  short for "interrupt 80" and causes the software interrupt
        int	$0x80

    //  It's possible to do this same thing with the sysenter
    //  instruction on an intel machine, but that's beyond where
    //  this demo will go.

    //  The number 1 represents the system call number SYS_exit */
	movl	$1,%eax
        int	$0x80


