Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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]#

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


Ïà¹ØÎĵµ£º

50¸öc/c++Ô´´úÂëÍøÕ¾

C/C++ÊÇ×îÖ÷ÒªµÄ±à³ÌÓïÑÔ¡£ÕâÀïÁгöÁË50ÃûÓÅÐãÍøÕ¾ºÍÍøÒ³Çåµ¥£¬ÕâЩÍøÕ¾Ìṩc/c++Ô´´úÂë¡£Õâ·ÝÇåµ¥ÌṩÁËÔ´´úÂëµÄÁ´½ÓÒÔ¼°ËüÃǵÄС˵Ã÷¡£ÎÒÒѾ¡Á¦°üÀ¨×î¼ÑµÄC/C++Ô´´úÂëµÄÍøÕ¾¡£Õâ²»ÊÇÒ»¸öÍêÕûµÄÇåµ¥£¬ÄúÓн¨Òé¿ÉÒÔÁªÏµÎÒ£¬ÎÒ½«»¶Ó­ÄúµÄ½¨Ò飬ÒÔ½øÒ»²½¼ÓÇ¿Õâ·½ÃæµÄÇåµ¥¡£
1¡¢http://snippets.dzone.com/tag/c/ --ÊýÒÔǧ¼Æ ......

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 ......

Can C beat RTL?


http://www.edn.com/article/457428-Can_C_beat_RTL_.php 
With the appearance of higher speeds and more DSP macrocells in low-cost FPGAs, more and more design teams are seeing the configurable chips not as glue but as a way to accelerate the inner loops of numerical algorithms, either in conjun ......

»ù±¾ÔËËãµ¥ÔªµÄ¸ß²ã´Î×ۺϣºC/C++ to RTL

±¾ÎÄÒÔ¼Ó·¨ÎªÀý£º[code]
//----------------------------------------------------
//adder.c
//---------------------------------------------------
void adder(int a, int b, int *sum)
{
        *sum = a + b;
}
[/code][size=3]
[/size]
HLS¹¤¾ß£¨AutoPilot£©×ÛºÏÖ®ºóµÄ½á¹ ......

½ñÌìÍíÉÏÔÙÓÃc ʵÏÖÒ»±é


#include <iostream>
#include <conio.h>
using namespace std;
typedef struct _INTTEST
{
        int a;        
}inttest;
int main()
{
    inttest* p=new inttest[3];
    p[1].a=10;
    cou ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ