ºìÁªLinuxÃÅ»§
Linux°ïÖú

ubuntuµ÷Óú¯Êý·ÖÎö

·¢²¼Ê±¼ä:2008-06-26 21:08:47À´Ô´:ºìÁª×÷Õß:Archive
×÷ÕߣºÄ¾ÓÐ

Ë×»°Ëµ365ÐУ¬¸ôÐÐÈç¸ôɽ£¨¶÷£¬ÎÒ˵µÄ£©¡£²»Í¬ÐÐÒµÓв»Í¬ÐÐÒµµÄ¹æ¾Ø£¬¶ø½ñÌì˵µÄ²Ù×÷ϵͳҲÈç´Ë£¬½ñÌìÎÒ¾ÍÉÁÁËÒ»ÏÂÑü¡£³ÌÐòºÜ¼òµ¥£¬´ó¸ÅÊÇÕâÑùµÄ¡£

ÒýÓÃ:
#include
int main()
{
char *msg = "mnzn";
printf("msg is %s", msg);
return 0;
}


ºÜ¼òµ¥°É£¬¿ÉÊÇÈÎƾÎÒÔÚx86-ubuntuµÄ64λ»úÆ÷ÉÏÔõôд»ã±à¾ÍÊDz»¶Ô£¬¸Õ²ÅͻȻ¿ªÇÏ£¬·´»ã±à¿´ÁË¿´£¬ÐÄÀïµÄÃÕÍÅÈ«²¿½âÊÍÇå³þÁË¡£

ÒýÓÃ:
1 |#include
2 |
3 |int main()
4 |{
5 | int a = 10;
6 | char b = 'a';
7 |
8 | printf("the number is %d, char is %c\n", a, b);
9 | return 0;
10 |}


½ÓÏÂÀ´À´¿´¿´·´»ã±àµÄ½á¹û°É

ÒýÓÃ:
File Edit Options Buffers Tools Help
1 |.section .rodata
2 |.LC0:
3 | .string "the number is %d, char is %c\n"
4 |
5 |.text
6 |.globl _start
7 |_start:
8 | # init stack frame
9 | pushq %rbp
10 | movq %rsp, %rbp
11 |
12 | # get local var
13 | subq $16, %rsp
14 |
15 | # int a = 10
16 | movl $10, -8(%rbp)
17 |
18 | # char b = 'a'
19 | movb $97, -1(%rbp)
20 |
21 | # call printf
22 | movsbl -1(%rbp),%edx
23 | movl -8(%rbp), %esi
24 | movl $.LC0, %edi
25 | movl $0, %eax
26 | call printf
27 |
28 | # call exit
29 | movl $0, %edi
30 | xor %eax, %eax
31 | call exit

----31 |-cc-:---F1 print.s ?? 1?? 24 02:40 (Assembler)--L31--C17--Bot
End of buffer


½á¹ûÀ´×ÔÎÒÃÇ¿É°®µÄ emacs

·ÖÎöÏ£º
µÚ9£¬10ÐпªÊ¼³õʼ»¯Õ»Ö¡
13ÐÐΪ¾Ö²¿±äÁ¿¿ª±Ù¿Õ¼ä
16£¬19Ϊ¾Ö²¿±äÁ¿¸³Öµ

½ñÌìµÄÖ÷½Ç¾ÍÊÇ22ÐпªÊ¼µÄº¯Êýµ÷Óã¬ÔÚÕâÀïÎÒ·¸ÁËÌ«Ö÷¹ÛµÄ´íÎ󣬾¹È»Ò»Ö»ÈÏΪÎÒÓõIJÙ×÷ϵͳҲÊÇÓöÑÕ»´«µÝ²ÎÊý£¬½á¹û²»¹ÜÔõôд¶¼ÊǶδíÎ󣬰¦£¬ÎüÈ¡½ÌѵÁË£¬¿´¿´°É£¬Èç¹ûÓÐÈý¸ö²ÎÊý£¬µÚÒ»¸ö²ÎÊýÓÃedi,µÚ¶þ¸ö²ÎÊýÓÃesi, µÚÈý¸ö²ÎÊýÓÃedx, ¶øÇÒÒª°ÑeaxÇå0£¬ Ó¦¸ÃÊÇ×÷Ϊ·µ»ØÖµ°É¡£

ͬÑùµÄµ÷Óà exitµÄʱºò ÎÒ·ÂÕÕÁËÉÏÃæµÄ·½·¨£¬Ã»ÓгöÏÖ´íÎó¡£Áí£¬¾ÍËã²»°ÑeaxÇå0£¬³ÌÐòÔÝʱû³ö´í£¬²»¹ýÊÖͷûÓÐ×ÊÁÏ¡£
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 0 ÌõÆÀÂÛ