Example Programs
A standard “Hello, world!” program for Linux on IA-32:
.data msg: .asciz "Hello, world!\n" # "asciz" will cause the assembler to append # the null byte that many C library routines # expect. The C library isn't being used in # the example. MSGLEN = . - msg # this will cause the assembler to count the number of bytes # between the label "msg" and here. The number will be 16, # as the null byte is included. .text .globl _start _start: movl $MSGLEN,%edx # argument 3 for write. Number of bytes to write. # A macro is used, which means the MSGLEN will be # replaced with the immediate value 0xf (15) during # assembly. Comparable to C preprocessor macros. movl $msg,%ecx # argument 2 for write. Pointer to data. movl $1,%ebx # argument 1. file descriptor number. (stdout=1, see article on file descriptors) movl $4,%eax # syscall number 4 = write(2) int $0x80 xorl %ebx,%ebx # argument for syscall. exit code = 0 (xor of a value with itself always equals 0) movl $1,%eax # syscall number 1 = exit(2) int $0x80A standard “Hello, world!” program for FreeBSD and Mac OS X on IA-32:
.data msg: .asciz "Hello, world!\n" MSGLEN = . - msg .text .globl _start _start: pushl $MSGLEN pushl $msg pushl $1 movl $4,%eax subl $4,%esp int $0x80 addl $16 pushl $0 movl $1,%eax subl $4,%esp int $0x80Read more about this topic: GNU Assembler
Famous quotes containing the word programs:
“We attempt to remember our collective American childhood, the way it was, but what we often remember is a combination of real past, pieces reshaped by bitterness and love, and, of course, the video pastthe portrayals of family life on such television programs as Leave it to Beaver and Father Knows Best and all the rest.”
—Richard Louv (20th century)
“Short of a wholesale reform of college athleticsa complete breakdown of the whole system that is now focused on money and powerthe womens programs are just as doomed as the mens are to move further and further away from the academic mission of their colleges.... We have to decide if thats the kind of success for womens sports that we want.”
—Christine H. B. Grant, U.S. university athletic director. As quoted in the Chronicle of Higher Education, p. A42 (May 12, 1993)