Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Linux Assembly "Hello World" Tutorial, CS 200

 
by Bjorn Chambless
Introduction
The following is designed familiarize the reader with programming in x86 (AT&T
style, that produced by gcc) assembly under Linux and how to interface assembly
and higher-level language code (i.e. C). The tutorial will also briefly cover
debugging your assembly using GDB.
This tutorial requires the following:
an i386 family PC running Linux
GCC, the GNU C-compiler
GDB, the GNU debugger command line debugger
The tutorial was developed on and tested with GCC version 2.95.4 and GDB 19990928 under Linux kernel 2.4.9
I highly recommend working through this tutorial with
"as"
and "gdb"

documentation close at hand.
Source Code
The process begins with a source code program. For example, hello.c
/* hello.c */
#include
main()
{
printf("hello\n").
}
which, when compiled and executed, prints a message
linuxbox> gcc -o hello hello.c
linuxbox> ./hello
hello
The actual compilation process can be viewed by including the -v
option
linuxbox> gcc -v -o hello hello.c
Reading specs from /usr/lib/gcc-lib/i386-linux/2.95.4/specs
gcc version 2.95.4 20010902 (Debian prerelease)
/usr/lib/gcc-lib/i386-linux/2.95.4/cpp0 -lang-c -v -D__GNUC__=2
-D__GNUC_MINOR__=95 -D__ELF__ -Dunix -D__i386__ -Dlinux -D__ELF__
-D__unix__ -D__i386__ -D__linux__ -D__unix -D__linux -Asystem(posix)
-Acpu(i386) -Amachine(i386) -Di386 -D__i386 -D__i386__ hello.c
/tmp/ccCGCFmG.i
GNU CPP version 2.95.4 20010902 (Debian prerelease) (i386 Linux/ELF)
#include "..." search starts here:
#include <...> search starts here: /usr/local/include
/usr/lib/gcc-lib/i386-linux/2.95.4/include /usr/include
End of search list.
The following default directories have been omitted from the search
path: /usr/lib/gcc-lib/i386-linux/2.95.4/../../../../include/g++-3
/usr/lib/gcc-lib/i386-linux/2.95.4/../../../../i386-linux/include
End of omitted list. /usr/lib/gcc-lib/i386-linux/2.95.4/cc1
/tm


Ïà¹ØÎĵµ£º

linuxÖ®gccÃüÁî

      ÔÚLinuxϽøÐÐCÓïÑÔ±à³Ì£¬±ØÈ»Òª²ÉÓÃGNU GCCÀ´±àÒëCÔ´´úÂëÉú³É¿ÉÖ´ÐгÌÐò¡£GccÖ¸ÁîµÄÒ»°ã¸ñʽΪ£º
Gcc [Ñ¡Ïî] Òª±àÒëµÄÎļþ [Ñ¡Ïî] [Ä¿±êÎļþ]¡£ÆäÖУ¬Ä¿±êÎļþ¿Éȱʡ£¬GccĬÈÏÉú³É¿ÉÖ´ÐеÄÎļþÃûΪ£º±àÒëÎļþ.out
¿´Ò»Ï¾­µäÈëÃųÌÐò"Hello World£¡"
# vi hello.c £¬±à¼­ÈçÏ£º
#inclu ......

LinuxµÄÏÂÔØÃüÁîwgetÏê½â

 WgetÊÇÒ»¸öÊ®·Ö³£ÓÃÃüÁîÐÐÏÂÔØ¹¤¾ß£¬¶àÊýLinux·¢Ðа汾¶¼Ä¬Èϰüº¬Õâ¸ö¹¤¾ß¡£Èç¹ûûÓа²×°¿ÉÔÚ http: //www.gnu.org/software/wget/wget.html ÏÂÔØ×îа汾£¬²¢Ê¹ÓÃÈçÏÂÃüÁî±àÒë°²×°£º
# tar zxvf wget-1.9.1.tar.gz
# cd wget-1.9.1
# ./configure
# make
# make install
ËüµÄÓ÷¨ºÜ¼òµ¥.
1£©Ö§³Ö¶ÏµãÏ ......

Éú²úÕß Ïû·ÑÕßÎÊÌâʵÏÖ (linuxÏÂCÓïÑÔ)

²Ù×÷ϵͳµÄÒ»¸ö¾­µäÎÊÌâÊÇ"Éú²úÕß-Ïû·ÑÕß"ÎÊÌâ, ÕâÉæ¼°Í¬²½ÐźÅÁ¿ºÍ»¥³âÐźÅÁ¿µÄÓ¦ÓÃ, ÔÚÕâÀï,ÎÒÓÃÏ̵߳Äͬ²½ºÍ»¥³âÀ´ÊµÏÖ.
/*
* author ÕÅÎÄ
* 2008/06/20
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <pthread.h>
#include <semaphore.h> ......

linuxÏÂÈçºÎÉèÖÃnfs¹²Ïí

ÍøÂçÎļþϵͳ£¨NFS£¬Network File System£©ÊÇÒ»ÖÖ½«Ô¶³ÌÖ÷»úÉϵķÖÇø£¨Ä¿Â¼£©¾­ÍøÂç¹ÒÔØµ½±¾µØÏµÍ³µÄÒ»ÖÖ»úÖÆ£¬Í¨¹ý¶ÔÍøÂçÎļþϵͳµÄÖ§³Ö£¬Óû§¿ÉÒÔÔÚ±¾µØÏµÍ³ÉÏÏñ²Ù×÷±¾µØ·ÖÇøÒ»ÑùÀ´¶ÔÔ¶³ÌÖ÷»úµÄ¹²Ïí·ÖÇø£¨Ä¿Â¼£©½øÐвÙ×÷¡£
ÔÚǶÈëʽLinux µÄ¿ª·¢¹ý³ÌÖУ¬¿ª·¢ÕßÐèÒªÔÚLinux ·þÎñÆ÷ÉϽøÐÐËùÓеÄÈí¼þ¿ª·¢£¬½»²æ±àÒëºó£¬Í¨Ó ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ