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

²Ù×÷ϵͳѧϰ±Ê¼Ç(14) CºÍ»ã±àÏ໥µ÷ÓÃ

; ±àÒëÁ´½Ó·½·¨
; (ld µÄ‘-s’Ñ¡ÏîÒâΪ“strip all”)
; gcc -c not link
;
; [root@XXX XXX]# nasm -f elf foo.asm -o foo.o
; [root@XXX XXX]# gcc -c bar.c -o bar.o
; [root@XXX XXX]# ld -s foo.o bar.o -o foobar
; [root@XXX XXX]# ./foobar
; the 2nd one
; [root@XXX XXX]#
extern choose ; int choose(int a, int b);
[section .data] ; Êý¾ÝÔÚ´Ë
num1st dd 3
num2nd dd 4
[section .text] ; ´úÂëÔÚ´Ë
global _start ; ÎÒÃDZØÐëµ¼³ö _start Õâ¸öÈë¿Ú£¬ÒÔ±ãÈÃÁ´½ÓÆ÷ʶ±ð¡£
global myprint ; µ¼³öÕâ¸öº¯ÊýΪÁËÈà bar.c ʹÓÃ
_start:
push num2nd ; ©·
push num1st ; ©§
call choose ; ©Ç choose(num1st, num2nd);
add esp, 4 ; ©¿
mov ebx, 0
mov eax, 1 ; sys_exit
int 0x80 ; ϵͳµ÷ÓÃ
; void myprint(char* msg, int len)
myprint:
mov edx, [esp + 8] ; len
mov ecx, [esp + 4] ; msg
mov ebx, 1
mov eax, 4 ; sys_write
int 0x80 ; ϵͳµ÷ÓÃ
ret


void myprint(char* msg, int len);
int choose(int a, int b)
{
if(a >= b){
myprint("the 1st one\n", 13);
}
else{
myprint("the 2nd one\n", 13);
}
return 0;
}

[root@localhost testc]# nasm -f elf foo.asm -o foo.o
[root@localhost testc]# gcc -c bar.c -o bar.o
[root@localhost testc]# ld -s foo.o bar.o -o foobar
[root@localhost testc]# ./foobar
the 2nd one
[root@localhost testc]#

±¾ÎÄÀ´Ô´ÓÚ ×Ô¼º¶¯ÊÖд²Ù×÷ϵͳ


Ïà¹ØÎĵµ£º

ÈçºÎд³öרҵµÄCÍ·Îļþ

×öµ½×¨Òµ£¬Ó¦¸ÃÊÇÿ¸öÖ°Òµ³ÌÐòÔ±Ó¦¸ÃÒªÇó×Ô¼º×öµ½µÄ¡£
ÈÃÎÒÃÇ¿´¿´lua
ÊÇ
ÔõôдͷÎļþµÄ¡£
1.License Agreement
License
Agreement
Ó¦¸Ã¼ÓÔÚÿ¸öÍ·ÎļþµÄ¶¥²¿¡£
Lua Sample:
/*
** $Id: lua.h,v 1.175b 2003/03/18 12:31:39 roberto Exp $
** Lua - An ......

fork compare to exec in linux c program

pid_t  pid=fork()
it has 3 situation for the return result pid
0  child
>0 parent process
<0 fork fail
fork create a new process  and it parent live alse when the child process had been created ......

ÈçºÎʹÓ÷ºÐÍÄ£擬virtual? (C/C++) (template)

ÍøÉÏÒ»µÀ½ðɽµÄÃæÊÔÌ⣺
http://topic.csdn.net/u/20100524/14/0eff992a-2849-4db6-bdaa-d4a200e79b7c.html
Çë·Ö±ðÓÃC++µÄÃæÏò¶ÔÏóºÍ·ºÐÍ»úÖÆ£¬±àдʵÏÖTemplate MethodģʽµÄʾÀý´úÂ룬²¢±È½ÏÁ½ÖÖ·½Ê½¸÷×ÔµÄÓÅȱµã¡£
ÓÃÐ麯ÊýʵÏÖTemplate MethodµÄ·½Ê½¾Í²»¶à˵ÁË¡£Ó÷ºÐ͵ķ½Ê½ÊµÏÖ¶à̬ÔÚATLÀïÃæÓдóÁ¿µÄÓõ½£¡
·ºÐ͵ ......

c/c++Êä³öºº×Ö

1. ʹÓÃTCHARÀàÐÍ£¬¶¨ÒåÔÚtchar.hÖÐ
#include <tchar.h>
#include <stdio.h>
int main()
{
 TCHAR s[] = "Äã";
 printf("%s \n",s);
 return 0;
}
2.¹ØÓÚC++ÖÐÎÄ×Ö·ûµÄ´¦Àí
 
Ò» ÒýÈëÎÊÌâ
´úÂë wchar_t a[3]=L”Öйú”£¬±àÒëʱ³ö´í£¬³ö´íÐÅϢΪ£ºÊý×éÔ½½ç¡£µ«wchar_ ......

Linux C ʵÏÖÏ̳߳Ø

×î½ü×öµÄһЩ¹¤×÷ÐèÒªÓõ½Ï̳߳ؼ¼Êõ£¬Òò´Ë²Î¿¼ÁËһЩ×ÊÁϺÍÊé¼®£¬È硶0bug c/c++ÉÌÓù¤³ÌÖ®µÀ¡·¡£
Ϊ´ËÔÚlinuxƽ̨ÉÏÓô¿cдÁËÒ»¸öÏ̳߳صÄʵÏÖ¡£
ÔÚ´ËÁгöÁËÔ­´úÂë¡£
Ö÷ÒªÓõ½µÄÊý¾Ý½á¹¹ÓÐ
1.struct  thread_pool_t    // thread pool µÄʵÏÖ´úÂë
2.struct thread_pool_token_t  &nb ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ