²Ù×÷ϵͳѧϰ±Ê¼Ç(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]#
±¾ÎÄÀ´Ô´ÓÚ ×Ô¼º¶¯ÊÖд²Ù×÷ϵͳ
Ïà¹ØÎĵµ£º
¿ìËÙÃÝÈ¡Ä£ÀíÂÛ»ù´¡£º ¼ÆËã a^b mod c ?
ÓÉ(a x b) mod c=((a mod c) x b) mod c.
ÎÒÃÇ¿ÉÒÔ½« bÏȱíʾ³É¾Í£º
b=at2^t+at-1 2^t-1+……a02^0. (ai=[0,1]).
ÕâÑùÎÒÃÇÓÉ a^b mod c=(a^(at2^t+at-12^t-1+…a02^0)mod c.
È»¶øÎÒÃÇÇó a^(2^(i+1)) ......
×Ö·û´®ÊÇCÓïÑԵľ«»ªÖ®Ò»£¬CÓïÑÔÊDZÊÊÔ¿¼ÌâµÄºËÐÄ֪ʶµã£¬²»¹ÜÄãÊÇѧc++£¬Ñ§java»¹ÊÇc#¡¢.net£¬»¹Êǽű¾Ê²Ã´µÄ£¬×îºÃ»¹ÊǶ®µãC°É£¬²»¶®C±ÊÊÔ»òÐí±È½Ï³Ô¿÷¡£ËùÒÔÔÚ±ÊÊÔÃæÊÔÖУ¬×Ö·û´®µÄÎÊÌâÊǾ³£³öÏֵģ¬ÆäÖÐÓÐÒ»ÀàÎÊÌâ¾ÍÊÇ×Ô¼ºÊµÏÖһЩ»ù±¾µÄC±ê×¼¿âµÄ×Ö·û´®´¦Àíº¯Êý»òÆäËûC±ê×¼¿âº¯Êý¡£
ÎÊÌâÒ»ÃèÊö£º Óñê×¼Cдһ¸öÅжϸ ......
±¾ÎÄÒÔ¼Ó·¨ÎªÀý£º[code]
//----------------------------------------------------
//adder.c
//---------------------------------------------------
void adder(int a, int b, int *sum)
{
*sum = a + b;
}
[/code][size=3]
[/size]
HLS¹¤¾ß£¨AutoPilot£©×ÛºÏÖ®ºóµÄ½á¹ ......
Ò». ÔÚ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 ......