²Ù×÷ϵͳѧϰ±Ê¼Ç(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ÓïÑÔÖеÄÔËËã·û¼°ÓÅÏȼ¶ÊǺÜÖØÒªµÄ£¬Ò»¶¨ÒªÀÃÊìÓÚÐÄ£¡
ÓÅÏȼ¶ ÔËËã·û º¬Òå ÒªÇóÔËËã¶ÔÏó¸öÊý ½áºÏ 1 ()
[]
->
. À¨ºÅÔËËã·û
ϱêÔËËã·û
½á¹¹Ìå³ÉÔ±ÔËËã·û ......
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 ......
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_ ......
Ò». ÔÚcÖзÖΪÕ⼸¸ö´æ´¢Çø
1.Õ» - ÓɱàÒëÆ÷×Ô¶¯·ÖÅäÊÍ·Å
2.¶Ñ - Ò»°ãÓɳÌÐòÔ±·ÖÅäÊÍ·Å£¬Èô³ÌÐòÔ±²»ÊÍ·Å£¬³ÌÐò½áÊøÊ±¿ÉÄÜÓÉOS»ØÊÕ
3.È«¾ÖÇø£¨¾²Ì¬Çø£©£¬È«¾Ö±äÁ¿ºÍ¾²Ì¬±äÁ¿µÄ´æ´¢ÊÇ·ÅÔÚÒ»¿éµÄ£¬³õʼ»¯µÄÈ«¾Ö±äÁ¿ºÍ¾²Ì¬±äÁ¿ÔÚÒ»¿éÇøÓò£¬Î´³õʼ»¯µÄÈ«¾Ö±äÁ¿ºÍδ³õʼ»¯µÄ¾²Ì¬±äÁ¿ÔÚÏàÁÚµÄÁíÒ»¿éÇøÓò¡£- ³ÌÐò½áÊøÊÍ·Å
4.ÁíÍ ......
#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 ......