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
Ïà¹ØÎĵµ£º
ÀýÒ»£º·¢ËÍSignaling Packet£º
Signaling CommandÊÇ2¸öBluetoothʵÌåÖ®¼äµÄL2CAP²ãÃüÁî´«Êä¡£ËùÒÔµÃSignaling CommandʹÓÃCID 0x0001.
¶à¸öCommand¿ÉÒÔÔÚÒ»¸öC-frame£¨control frame£©Öз¢ËÍ¡£
Èç¹ûÒªÖ±½Ó·¢ËÍSignaling Command.ÐèÒª½¨Á¢SOCK_RAWÀàÐ͵ÄL2CAPÁ¬½ÓSocket¡£ÕâÑù²ÅÓлú»á×Ô¼ºÌî³äCommand Code£¬Identi ......
Æô¶¯armlinux£¬bootloader±ØÐëÌṩÏÂÃ漸²½£º
1£® ÉèÖò¢³õʼ»¯ram
2£® ³õʼ»¯Ò»¸ö´®¿Ú
3£® ¼ì²â´¦ÀíÆ÷ÀàÐÍ
4£® ÉèÖÃÄں˱ê¼ÇÁбí
5£® µ÷ÓÃÄÚºËÓ³Ïñ
1. ÉèÖò¢³õʼ»¯ram
bootloaderÒªÕÒµ½²¢³õʼ»¯ÏµÍ³ÖÐËùÓе ......
Ê×ÏÈÐèÒª°²×°Red5ÔËÐÐËùÐèµÄjava¿ª·¢»·¾³jdk,ÎÒËùÓеÄÎļþ¶¼±£´æµ½/root/download,°²×°ÒªÓÃroot
¡¡¡¡Óû§½øÐа²×°
¡¡¡¡ÏÂÔصØַΪhttps://sdlc6e.sun.com/ECom/EComActionServlet;jsessionid= 8CEC5D9DFF18A14B277B3C32456062B1ÎÒÏÂÔصÄÊÇÀàÐÍLinux RPM in self-extracting file µÄÎļþ£¬ÎļþÃûΪ
¡¡¡¡jdk-1_5_0_0 ......
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£©Ö§³Ö¶ÏµãÏ ......
¼Ç¼³£ÓòÙ×÷£º
Îļþ¼°Îļþ¼ÐÏà¹Ø
=======================================================================
Îļþ²Ù×÷(rm)£»
Îļþ¼Ð²Ù×÷£¨rmdir ɾ³ý¿ÕÎļþ£¬rm -rf Ŀ¼Ãûɾ³ý·Ç¿ÕÎļþ¼Ð£©;
ÎļþÒƶ¯£ºmv cp¶¼¿ÉÒÔ£»
½âѹËõ£ºtar
¸ñʽ£º tar Ñ¡Ïî ÎļþĿ¼Áбí
¹¦ÄÜ£º ¶ÔÎļþÄ¿ ......