思方網 : [H28] 決策理論
人生在世總難免要做決策或決定。早上吃雙腸蛋還是肉丁米粉?應安坐家中抑或上街遊行?該與A君還是與B君結婚?重返校園還是繼續在社會打滾? 這等問題都是我們日復日要面對的決策問題。有些決策做錯了並無傷大雅。比方說,你選了部爛片觀看而白白浪費了整個下午也許會令你很氣憤,但卻不會對你的人生做成多大損失。然而,在某些事情做錯了決策卻可能會令你抱憾終生,甚至萬劫不復。譬如說,錯誤投資而輸了整副家財就可能會令你妻離子散。
如何作理性的決策構成決策理論的中心課題。較精確地說,決策理論是一門研究決策者在不同處境下該如何選擇才最為理性的學問。決策論與游戲理論皆為研究決策的學問,兩者的主要不同在於前者只研究個人的決策;後者則考慮涉及多於一人的決策情境。
必需指出一點,決策理論只能告訴你怎樣做決策最理性,並不能擔保你每次也能獲得好結果。最理性的決策未必會導至最好的結果。最好的結果也不一定來自最理性的決策。簡言之,理性的決策與結果的好壞並無必然聯系。畢竟,結果的好壞總難免摻雜運氣的因素。
當代的決策理論已被發展成一高度技術性的學科(通常被視作應用數學的一分支)。本導修課將避開所有技術細節,只對此理論作簡要的介紹。
典型的決策情境涉及決策者面對兩個或以上的相互排斥的選擇 (所謂「相互排斥」的選擇,即不可能同時並存的選擇。) 。決策論者通常把決策情境分為以下三類:
1. 風險下的決策情境
2. 確定性下的決策情境
3. 不確定性下的決策情境
讓我們首先考慮第一類處境。
風險下的決策
每個行動通常也能引發若干可能後果。當決策者能評估可選擇的每個行動的各個可能後果發生的機率時,我們稱他面對的處境為「風險下的決策情境」。以下情境便為一例:小強眼疾日深而漸趨失明。醫生對他說,接受移殖眼角膜手術將可能改善他的視力。但手術並非無風險 —— 手術成功的機會只有0.7。若手術失敗,他視力更壞的機率為0.1,維持手術前的視力水平的機率為0.2。假設小強若不做手術,他的視力將維持原狀。小強面對的決策情境將可以下圖表示:
行動
行動的可能後果
視力有改善 視力維持原狀 視力更壞
1.做手術
0.7
0.2
0.1
2.不做手術
0
1
0
再舉一個例子。小白正考慮選擇以下哪一種賭博游戲對他最有利。(一) 公字 :若投擲的貨幣表面是公,他則贏取10元,若為字,則不能贏取分毫 (假設貨幣為一公平的銅幣,故此出現公或字的機會各為0.5。。(二) 骰子 :莊家每次擲出兩枚骰子,若兩枚骰子點數相同,他則贏得十元,若否,則分毫也不能獲得。(我們從簡單的機率計算得知,兩枚骰子點數相同的機率約為0.167,點數不同的機率約為0. 833) 讓我們假設小白的賭博本金為5元。面對的決策情境將可以下圖表示:
行動
行動的可能後果
贏得0元
贏得10元
1. 公字
0.5
0.5
2. 骰子
0.167
0.833
在這些情境下我們該選擇哪一行動才最理性?決策論者認為以下規則雖非毫無瑕疵,在一般情形下提供我們合理的指示:
最大化期望值或稱期望效用原則: 決策者應選取能給予他最大期望值的行動。
假設決策者面前有N個行動選擇。根据此原則,決策者應計算每個行動分別對應的期望值,然後選擇期望值最高的行動而行。涉及金錢的處境最易說明此原則之應用。以例二為例,行動1及2分別對應的期望值(及其計算方法如下所示:
行動
期望值
1. 公字
(0.5 x 10) + (0.5 x 0) -5 = 0
2. 骰子
(0.167 x 10) + (0.833x0) = -3.33
因此,最大化期望值原則告訴我們應選行動1而行。
當回報並非為明顯可量化的事項 (如金錢時,應用此原則將較麻煩。例如在例一中我們不能像例二般把金錢直接轉換成期望值,要計算做手術與不做手術的期望值則須略花心思。以下為一可能建議:我們可替聯系行動1及2的可能後果各指派一個值,如下:
行動1:
視力有改善 (10),視力維持原狀 (-2),及視力更壞 (-10)
行動2:
視力維持原狀 (0)
行動1的期望值 = (10 x 0.7) + (-2 x 0.2 )+ (-10 x 0.1) = 5.6
行動2的期望值 = 0 x 1 = 0
確定性下的決策
在某些情況下,決策者能選擇的行動每個也只有一個可能後果。這種情況稱作確定性下的決策情境。下面就為一例:
行動
行動的可能後果
1 在家寫論文
在家寫論文
2 在圖書館寫論文
在圖書館寫論文
若你選擇行動1,這行動的可能後果就是你在家寫論文;若選擇行動2,這行動的可能後果就是你在圖書館寫論文。
嚴格而言,世上根本不存在上述的決策情境。在你決定行動那刻到履行行動之間,世事已可能以你難以預料的方式改變。例如說,經過一輪考慮後,你決定到圖書館完成那惱人的論文。然而,到達圖書館之時卻發現館內因停電而閉館。畢竟,世事變幻莫測,確定性也許只是幻象。
既然在這種決策情境下行動的可能後果只有一個,顯然我們並不需為計算期望值而費神。那麼,在這情況下該以什麼作為行動的准則?答案明顯得很 —— 比較各行動後果的效用而選具效用最高者而行。 比方,若你認為在家寫論文的效用不及在圖書館,那你則應擇行動2而棄行動1。
然而,比較行動後果效用並非總是易事。比方說你正考慮該購買愉翠苑還是錦豐苑的單位。你該如何比較兩者的效用?比較首期及月供之金額故然應列入考慮因素。然而,除此之外,你也許需考慮其他與金錢無關之事。例如,哪屋苑治安較佳?錦豐苑交通是否較方便?愉翠苑的樓宇是否穩固 (早前曾發生短樁事件。兩者中衛生設備何者較佳?比較效用往往因需慮及這等因素而變得複雜棘手。
不確定性下的決策
決策者有時可能對可供選擇的行動之後果的發生機率一無所知。這種情境稱作「不確定性下的決策情境」。
亳無疑問,這種情況甚為罕見。在大多數情況下,我們也能粗略評估不同可能後果發生的機率。股票投資也許為最符合這種不確定情境之例 (至少就非專業的投資者而言。故我們不妨以此投資對此情境作說明。
假設股壇新秀方展博正欲在股場一試身手。在他腦海正盤算著四種投資策略:(1)投資$8,000,(2)投資$4,000, (3)投資$2,000,及(4)投資$1,000。方先生雖能預計各個投資策略的可能結果,卻無能評估它們發生的可能性。下面回報表表示他的決策情境:
行動
行動的可能後果
牛市
普通市
熊市
$8000
$800
$200
-$400
$4000
$400
$100
-$200
$2000
$200
$50
-$100
$1000
$100
$25
-$50
方先生應選擇何種投資策略?
既然方先生對可能結果發生的機率完全無知,最大化期望值原則顯然派不上用場。故此,他只能求助其他原則。實際上,在此情況下有至少兩條原則可助方先生作理性決策,選取何者則視乎他的個性取向。
若方先生為審慎保守之徒,那他應依從以下原則:
最大最小化原則: 決策者應先比較可供選擇的每個行動的最壞可能後果,然後選擇引起最壞後果之中的最佳後果之行動。
在上表中,我們看到行動1- 4的最壞後果分別為 - $400, -$200, -$100, 及 $50。行動4引發的最壞後果較其餘行動佳(故稱它「最壞之中的最佳」) ,因此方先生應選擇行動4。
假若方先生較富冒險精神,那以下原則較適合他:
最大最大化原則: 決策者應先比較可供選擇的每個行動的最佳可能後果,然後選擇引起最佳後果之中的最佳後果之行動。
行動1-4的最佳後果分別為$800,$400,$200,及$100。很易看出,行動1為引起最佳之中的最佳的行動。因此,方先生應選擇行動1。
2008年12月27日 星期六
傳真信-1
2.1 What is a Fax?(什麼是傳真)
Fax (abbreviation of facsimile) is a process by which fixed graphic material including pictures, text, or images is scanned and the information converted into electrical signals which are transmitted via telephone to produce a paper copy of the graphics on the receiving fax machine.
Fax machine (abbreviation of facsimile machine) is a device that can send or receive pictures and text over a telephone line. The fax machine translates a picture into a series of zeros and ones (bit map) that can be transmitted like normal computer data.
translates the zeros and ones back into dots, and reprints the picture. A fax machine consists of an optical scanner for digitizing images on paper, a printer for printing incoming fax messages, and a telephone for making the connection. Some printers on fax machines are thermal, which means they require a special kind of paper.
2.2 The Layout of a Fax(傳真的格式)
To: (the name of the receiver)
Fax: (fax number)
From: Your Name
Date: 5/15/2006
Pages: total number of pages
Deer Mr./ Mrs.,
(Body)
Yours sincerely,
Your name
2. 3. 1 Example one: Invitation to a conference (邀請參加會議)
To: Mr. Conrad Smith
Fax: 1-403-5561772 Tel: 1-403-5561771
From: Cuo Yan
Fax: 8621-65547880 Tel: 8621-65547881
Date: 9/10/2(105
Number of pages to follow: 1
Dear Mr. Smith,
We’ll hold a conference on Learning English as a Second Language in Shanghai, China on the 25th of November 2006. You’ll be invited to join the Conference if you’re interested in it. Please contact us before November 1st as we can prepare a formal invitation letter for you.
Best regards!
Guo Yan
2. 3. 2 Example two: About an urgent sales issue 緊急銷售業務的傳真
To:
Fax: Tel:
From :
Fax: Tel:
Date :
Number of pages to follow:
Dear,
Several weeks ago, you requested information on our line of printers and we were pleased to send you our brochure.
Perhaps you have additional questions about the printer we offer. To help you make the right decision, we ate enclosing a sheet that answers the most commonly, asked questions about our line.
Sincerely,
Name
Title
2. 3. 3 Example three: Turning down an offer 拒絕對方報價
To:
Fax : Tel :
From:
Fax : Tel :
Date:
Number of pages to follow:
Dear,
Thank you for your offer of 20th November for 10, 000 sets of photocopier.
We regret being unable to make use of goods as the price you ask is above the market level here for the quality in question.
The copiers supplies here covering the same brand are not of the quality we have expected for the price quoted.
Yours sincerely,
Name
Title
Fax (abbreviation of facsimile) is a process by which fixed graphic material including pictures, text, or images is scanned and the information converted into electrical signals which are transmitted via telephone to produce a paper copy of the graphics on the receiving fax machine.
Fax machine (abbreviation of facsimile machine) is a device that can send or receive pictures and text over a telephone line. The fax machine translates a picture into a series of zeros and ones (bit map) that can be transmitted like normal computer data.
translates the zeros and ones back into dots, and reprints the picture. A fax machine consists of an optical scanner for digitizing images on paper, a printer for printing incoming fax messages, and a telephone for making the connection. Some printers on fax machines are thermal, which means they require a special kind of paper.
2.2 The Layout of a Fax(傳真的格式)
To: (the name of the receiver)
Fax: (fax number)
From: Your Name
Date: 5/15/2006
Pages: total number of pages
Deer Mr./ Mrs.,
(Body)
Yours sincerely,
Your name
2. 3. 1 Example one: Invitation to a conference (邀請參加會議)
To: Mr. Conrad Smith
Fax: 1-403-5561772 Tel: 1-403-5561771
From: Cuo Yan
Fax: 8621-65547880 Tel: 8621-65547881
Date: 9/10/2(105
Number of pages to follow: 1
Dear Mr. Smith,
We’ll hold a conference on Learning English as a Second Language in Shanghai, China on the 25th of November 2006. You’ll be invited to join the Conference if you’re interested in it. Please contact us before November 1st as we can prepare a formal invitation letter for you.
Best regards!
Guo Yan
2. 3. 2 Example two: About an urgent sales issue 緊急銷售業務的傳真
To:
Fax: Tel:
From :
Fax: Tel:
Date :
Number of pages to follow:
Dear,
Several weeks ago, you requested information on our line of printers and we were pleased to send you our brochure.
Perhaps you have additional questions about the printer we offer. To help you make the right decision, we ate enclosing a sheet that answers the most commonly, asked questions about our line.
Sincerely,
Name
Title
2. 3. 3 Example three: Turning down an offer 拒絕對方報價
To:
Fax : Tel :
From:
Fax : Tel :
Date:
Number of pages to follow:
Dear,
Thank you for your offer of 20th November for 10, 000 sets of photocopier.
We regret being unable to make use of goods as the price you ask is above the market level here for the quality in question.
The copiers supplies here covering the same brand are not of the quality we have expected for the price quoted.
Yours sincerely,
Name
Title
英文 問候 有此一說
早安good morning「念法:谷 摸 ㄋㄧㄥˇ」
午安good afternoon「念法:谷 A 府(輕音) ㄊㄜ ㄋㄨㄣˋ」
晚安good evening「念法:谷 一 府(輕音) ㄋㄧㄥˇ」(晚上時用)
good night「念法:谷 奈」(睡覺前用)
午安good afternoon「念法:谷 A 府(輕音) ㄊㄜ ㄋㄨㄣˋ」
晚安good evening「念法:谷 一 府(輕音) ㄋㄧㄥˇ」(晚上時用)
good night「念法:谷 奈」(睡覺前用)
vb 20080104 前將作業上傳
For i=1 TO 5
a(i)=Rnd()*10
K=a(i)
Loop While B(K)=1
Next
for next 連續做五次(不管原因)
Loop 迴圈(一直做)
比較大小 排序
For x=1 TO 4
FOR y=x+1 TO 5
IF a(X) > a(y) THEN
temp =a(X) -->X.Y 對調(IF 大小位置對調)
a(X)=a(y)
a(y)=TEMP
END IF
NEXT
NEXT
(1)X=1
Y=2~5
X=1 Y=2 a(1)>a(2) X=1 Y=2 7.8.4.1.6
X=1 Y=2 a(1)>a(3) X=1 Y=3 4.8.7.1.6
X=1 Y=2 a(1)>a(4) X=1 Y=4 1.8.7.4.6
X=1 Y=2 a(1)>a(5) X=1 Y=5 1.8.7.4.6
X=1 Y=2 a(1)>a(3) X=2 Y=3 1.7.8.4.6
X=1 Y=2 a(1)>a(4) X=2 Y=4 1.4.8.7.6
X=1 Y=2 a(1)>a(5) X=2 Y=5 1.4.8.7.6
X=1 Y=2 a(1)>a(4) X=3 Y=4 1.4.8.7.6
X=1 Y=2 a(1)>a(5) X=3 Y=5 1.4.6.8.7
X=1 Y=2 a(1)>a(5) X=4 Y=5 1.4.6.7.8
題目:
(1)X=1
IF X=2 and Y=3 THEN
Msgbox (a(1)&","&a(2).........a(5)
ENDIF
a(i)=Rnd()*10
K=a(i)
Loop While B(K)=1
Next
for next 連續做五次(不管原因)
Loop 迴圈(一直做)
比較大小 排序
For x=1 TO 4
FOR y=x+1 TO 5
IF a(X) > a(y) THEN
temp =a(X) -->X.Y 對調(IF 大小位置對調)
a(X)=a(y)
a(y)=TEMP
END IF
NEXT
NEXT
(1)X=1
Y=2~5
X=1 Y=2 a(1)>a(2) X=1 Y=2 7.8.4.1.6
X=1 Y=2 a(1)>a(3) X=1 Y=3 4.8.7.1.6
X=1 Y=2 a(1)>a(4) X=1 Y=4 1.8.7.4.6
X=1 Y=2 a(1)>a(5) X=1 Y=5 1.8.7.4.6
X=1 Y=2 a(1)>a(3) X=2 Y=3 1.7.8.4.6
X=1 Y=2 a(1)>a(4) X=2 Y=4 1.4.8.7.6
X=1 Y=2 a(1)>a(5) X=2 Y=5 1.4.8.7.6
X=1 Y=2 a(1)>a(4) X=3 Y=4 1.4.8.7.6
X=1 Y=2 a(1)>a(5) X=3 Y=5 1.4.6.8.7
X=1 Y=2 a(1)>a(5) X=4 Y=5 1.4.6.7.8
題目:
(1)X=1
IF X=2 and Y=3 THEN
Msgbox (a(1)&","&a(2).........a(5)
ENDIF
2008年12月14日 星期日
hp_server_CKH_linux_setup_flow
hp_server_CKH_linux_setup_flow
1:) 用 HP 附的 SmartStart 開機
2:) 用 Maintain 的 Erase 工具將 所有之前裝過的 os 及 硬碟資料全部刪除
3:) 用 Maintain 的 Raid 工具, 重新建立 raid (建議 選 raid5)
4:) Fedora 用裝時, 選 srever --> 保留所有分割區,並使用現有分割
灌好後 若無法機-->
開機後 有好幾層 的 setup 都是 按 F8,
其中有一層 可按 F8進入設定 boot drive
(該層 進入後 有 4個設定, 都跟 raid 有關, 最後一個 即為 active boot drive)
選完後, 以後進來就只有 3個設定
不過若以後 做過 2:) 就 得再做一次 active boot driver
1:) 用 HP 附的 SmartStart 開機
2:) 用 Maintain 的 Erase 工具將 所有之前裝過的 os 及 硬碟資料全部刪除
3:) 用 Maintain 的 Raid 工具, 重新建立 raid (建議 選 raid5)
4:) Fedora 用裝時, 選 srever --> 保留所有分割區,並使用現有分割
灌好後 若無法機-->
開機後 有好幾層 的 setup 都是 按 F8,
其中有一層 可按 F8進入設定 boot drive
(該層 進入後 有 4個設定, 都跟 raid 有關, 最後一個 即為 active boot drive)
選完後, 以後進來就只有 3個設定
不過若以後 做過 2:) 就 得再做一次 active boot driver
c++
#include
using namespace std;
int main()
{
int s,sum=0,count=0,good=0;
while(true){
cout << "請輸入程設分數:";
cin >> s;
if (s==0)
break;
sum+=s;
count++;
if ( s>=60 )
good++;
}
cout<<"你共輸入"<< count <<"位成績平均分數為"<< sum/count;
cout<< good <<"及格"<< count-good <<"不及格";
using namespace std;
int main()
{
int s,sum=0,count=0,good=0;
while(true){
cout << "請輸入程設分數:";
cin >> s;
if (s==0)
break;
sum+=s;
count++;
if ( s>=60 )
good++;
}
cout<<"你共輸入"<< count <<"位成績平均分數為"<< sum/count;
cout<< good <<"及格"<< count-good <<"不及格";
哈佛圖書館自習室牆上 的訓言
哈佛圖書館自習室牆上 的訓言
可能大家看過, 貼出來與大家共勉.
1.此刻打盹,你將做夢;而此刻學習,你將圓夢。
2.我荒廢的今日,正是昨日殞身之人祈求的明日。
3.覺得為時已晚的時候,恰恰是最早的時候。
4.勿將今日之事拖到明日。
5.學習時的苦痛是暫時的,未學到的痛苦是終生的。
6.學習這件事,不是缺乏時間,而是缺乏努力。
7.幸福或許不排名次,但成功必排名次。
8.學習並不是人生的全部。但,既然連人生的一部分——學習也無法征服,還能做什麼呢?
9.請享受無法迴避的痛苦。
10.只有比別人更早、更勤奮地努力,才能嘗到成功的滋味。
11.誰也不能隨隨便便成功,它來自徹底的自我管理和毅力。
12.時間在流逝。
13.現在淌的哈喇子,將成為明天的眼淚。
14.狗一樣地學,紳士一樣地玩。
15.今天不走,明天要跑。
16.投資未來的人是,忠於現實的人。
17.教育程度代表收入。
18.一天過完,不會再來。
19.即使現在,對手也不停地翻動書頁。
20.沒有艱辛,便無所獲。
附上英文版:
1. This moment will nap, you will have a dream; But this moment study,you will interpret a dream.
2. I leave uncultivated today, was precisely yesterday perishestomorrow which person of the body implored.
3. Thought is already is late, exactly is the earliest time.
4. Not matter of the today will drag tomorrow.
5. Time the study pain is temporary, has not learned the pain islife-long.
6. Studies this matter, lacks the time, but is lacks diligently.
7. Perhaps happiness does not arrange the position, but succeeds mustarrange the position.
8. The study certainly is not the life complete. But, sincecontinually life part of - studies also is unable to conquer, what butalso can make?
9. Please enjoy the pain which is unable to avoid.
10. Only has compared to the others early, diligently diligently, canfeel the successful taste.
11. Nobody can casually succeed, it comes from the thoroughself-control and the will.
12. The time is passing.
13. Now drips the saliva, will become tomorrow the tear.
14. The dog equally study, the gentleman equally plays.
15. Today does not walk, will have to run tomorrow.
16. The investment future person will be, will be loyal to the realityperson.
17. The education level represents the income.
18. One day, has not been able again to come.
19. Even if the present, the match does not stop changes the page.
20. Has not been difficult, then does not have attains.
可能大家看過, 貼出來與大家共勉.
1.此刻打盹,你將做夢;而此刻學習,你將圓夢。
2.我荒廢的今日,正是昨日殞身之人祈求的明日。
3.覺得為時已晚的時候,恰恰是最早的時候。
4.勿將今日之事拖到明日。
5.學習時的苦痛是暫時的,未學到的痛苦是終生的。
6.學習這件事,不是缺乏時間,而是缺乏努力。
7.幸福或許不排名次,但成功必排名次。
8.學習並不是人生的全部。但,既然連人生的一部分——學習也無法征服,還能做什麼呢?
9.請享受無法迴避的痛苦。
10.只有比別人更早、更勤奮地努力,才能嘗到成功的滋味。
11.誰也不能隨隨便便成功,它來自徹底的自我管理和毅力。
12.時間在流逝。
13.現在淌的哈喇子,將成為明天的眼淚。
14.狗一樣地學,紳士一樣地玩。
15.今天不走,明天要跑。
16.投資未來的人是,忠於現實的人。
17.教育程度代表收入。
18.一天過完,不會再來。
19.即使現在,對手也不停地翻動書頁。
20.沒有艱辛,便無所獲。
附上英文版:
1. This moment will nap, you will have a dream; But this moment study,you will interpret a dream.
2. I leave uncultivated today, was precisely yesterday perishestomorrow which person of the body implored.
3. Thought is already is late, exactly is the earliest time.
4. Not matter of the today will drag tomorrow.
5. Time the study pain is temporary, has not learned the pain islife-long.
6. Studies this matter, lacks the time, but is lacks diligently.
7. Perhaps happiness does not arrange the position, but succeeds mustarrange the position.
8. The study certainly is not the life complete. But, sincecontinually life part of - studies also is unable to conquer, what butalso can make?
9. Please enjoy the pain which is unable to avoid.
10. Only has compared to the others early, diligently diligently, canfeel the successful taste.
11. Nobody can casually succeed, it comes from the thoroughself-control and the will.
12. The time is passing.
13. Now drips the saliva, will become tomorrow the tear.
14. The dog equally study, the gentleman equally plays.
15. Today does not walk, will have to run tomorrow.
16. The investment future person will be, will be loyal to the realityperson.
17. The education level represents the income.
18. One day, has not been able again to come.
19. Even if the present, the match does not stop changes the page.
20. Has not been difficult, then does not have attains.
組合語言大家為何不敢玩
不知道能不能有一個適合我磨練的環境和機會?
一般而言, 組合語言比較適用於發展Firmware or BIOS的領域, Driver可能會用到一點, 目前有需求的廠商(Micro processor, Chipsets, PC Motherboard/system 的Designer/Manufacturer), 在這部分比較傾向找有經驗的, 完全不懂的也是有機會但是很少可能要看運氣。
最低限度會找了解組合語言的人進去後on job training。
想問您,為什組合語言大家都不敢去碰呢?
組合語言在語法上太接近機器語言, 而不像一般高階語言比較接近人類的數學敘述, 在學習、認知上會有比較多的挫折。
還有, 組合語言除了需要學習語法更需要了解CPU架構, 個人覺得最關鍵的是記憶體位址的觀念(尤其是Intel X86 CPU有所謂的 segment暫存器)以及其定址法的運用,
另外在存取IO裝置除了一般的IO位址還須了解index port/data port的觀念。
For details about the answer of your question, refer to the attached “Forward” of the book The Art of Assembly Language.
關於組合語言的語法與CPU(8051 or X86)的基本觀念可以參考市面上的一些書籍, 但若是想深入了解CPU architecture則須參考各家製造商的Data Sheet, 這部分很需要讀英文的功力;
這個URL可以找到並下載Intel X86 CPU的官方詳細資料: http://www.intel.com/design/pentium4/manuals/index_new.htm#sdm_vol1。
組合語言和硬體的那些方面有關呢?
所有可以被程式控制的硬體功能都可以由組合語言達成
可以直接存取CPU的各種 register, 控制CPU的各種功能, 讓CPU進入各種狀態
可以直接access記憶體的內容, 可以定址到任何位址
可以直接存取IO位址(大部分是一些IO裝置或是擴充卡內的 register or data buffer)
可以執行所有的CPU指令 (包括compiler不懂的指令)
能用在那些東西上面呢?
因為組合語言可以很輕易的控制到硬體-->用於撰寫成硬體啟始的控制程式 ,又 , 編譯連結後的執行碼所佔的空間比較小-->可以燒錄在空間並不是很大(相對於RAM or Disk)的ROM之內
所以傳統上用於發展PC的BIOS 或是一些微控制器系統的Firmware
Develop compiler or linker
Reverse-engineering.
On the bad side: viruses programming, security attacker,…
一般而言, 組合語言比較適用於發展Firmware or BIOS的領域, Driver可能會用到一點, 目前有需求的廠商(Micro processor, Chipsets, PC Motherboard/system 的Designer/Manufacturer), 在這部分比較傾向找有經驗的, 完全不懂的也是有機會但是很少可能要看運氣。
最低限度會找了解組合語言的人進去後on job training。
想問您,為什組合語言大家都不敢去碰呢?
組合語言在語法上太接近機器語言, 而不像一般高階語言比較接近人類的數學敘述, 在學習、認知上會有比較多的挫折。
還有, 組合語言除了需要學習語法更需要了解CPU架構, 個人覺得最關鍵的是記憶體位址的觀念(尤其是Intel X86 CPU有所謂的 segment暫存器)以及其定址法的運用,
另外在存取IO裝置除了一般的IO位址還須了解index port/data port的觀念。
For details about the answer of your question, refer to the attached “Forward” of the book The Art of Assembly Language.
關於組合語言的語法與CPU(8051 or X86)的基本觀念可以參考市面上的一些書籍, 但若是想深入了解CPU architecture則須參考各家製造商的Data Sheet, 這部分很需要讀英文的功力;
這個URL可以找到並下載Intel X86 CPU的官方詳細資料: http://www.intel.com/design/pentium4/manuals/index_new.htm#sdm_vol1。
組合語言和硬體的那些方面有關呢?
所有可以被程式控制的硬體功能都可以由組合語言達成
可以直接存取CPU的各種 register, 控制CPU的各種功能, 讓CPU進入各種狀態
可以直接access記憶體的內容, 可以定址到任何位址
可以直接存取IO位址(大部分是一些IO裝置或是擴充卡內的 register or data buffer)
可以執行所有的CPU指令 (包括compiler不懂的指令)
能用在那些東西上面呢?
因為組合語言可以很輕易的控制到硬體-->用於撰寫成硬體啟始的控制程式 ,又 , 編譯連結後的執行碼所佔的空間比較小-->可以燒錄在空間並不是很大(相對於RAM or Disk)的ROM之內
所以傳統上用於發展PC的BIOS 或是一些微控制器系統的Firmware
Develop compiler or linker
Reverse-engineering.
On the bad side: viruses programming, security attacker,…
2008年12月9日 星期二
文章名稱:人間 失格 高樹少年之死 讀書會
--------------------------------------------------------------------------------
2008 12/9 婉宜分享心得
如果 發生再 進專資二甲
這事件將 不會發生
因為 我們有各英明的班代
因為 進專 資二甲的同學 優秀 又團結
所以 這事件 我相信絕對不會發生
說起當時事件
我認為 學生素質絕對是各很大的問題
再來 家長絕對也有問題
通常家長 都要了解 學生的特質
再來決定 是不是 需要轉學的打算
學生本身 也是有問題
當事情在一開始 錯誤時 就應該 告知家長
家長當時 應該就要報警處理
之後 家長就要有轉學的打算
這事件 我相信就不會發生了
且 發生當時
應該要封鎖 現場不可以破壞案發現場
才能讓警方 好辦案
2008 12/9 婉宜分享心得
如果 發生再 進專資二甲
這事件將 不會發生
因為 我們有各英明的班代
因為 進專 資二甲的同學 優秀 又團結
所以 這事件 我相信絕對不會發生
說起當時事件
我認為 學生素質絕對是各很大的問題
再來 家長絕對也有問題
通常家長 都要了解 學生的特質
再來決定 是不是 需要轉學的打算
學生本身 也是有問題
當事情在一開始 錯誤時 就應該 告知家長
家長當時 應該就要報警處理
之後 家長就要有轉學的打算
這事件 我相信就不會發生了
且 發生當時
應該要封鎖 現場不可以破壞案發現場
才能讓警方 好辦案
VB數字排序程式碼
參考看看.. 有更好的方法,再請同學指教!!
=====================================
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x, i As Integer
If IsNumeric(TextBox1.Text) = True And IsNumeric(TextBox2.Text) = True And IsNumeric(TextBox3.Text) = True And IsNumeric(TextBox4.Text) = True Then
If textbox1.text = textbox2.text Or textbox1.text = textbox3.text Or textbox1.text = textbox4.text Or textbox2.text = textbox3.text Or textbox2.text = textbox4.text Or textbox3.text = textbox4.text Then
MsgBox("數字不得重覆!!")
Else
For i = 1 To 6
If textbox1.text < textbox2.text Then
If textbox2.text < textbox3.text Then
If textbox3.text < textbox4.text Then
Exit For
Else
x = textbox4.text
textbox4.text = textbox3.text
textbox3.text = x
End If
Else
x = textbox3.text
textbox3.text = textbox2.text
textbox2.text = x
End If
Else
x = textbox2.text
textbox2.text = textbox1.text
textbox1.text = x
End If
Next
MsgBox(textbox1.text & "," & textbox2.text & "," & textbox3.text & "," & textbox4.text)
End If
Else
MsgBox("欄位不得空白或特殊符號!!請重新輸入!")
End If
End Sub
End Class
=====================================
我有修改了一下,請同學幫忙看是否有問題..
如果沒問題的話,做『由大到小』就把 < 換成 > 應該就可以了!!
對調一下
=====================================
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim x, i As Integer
If IsNumeric(TextBox1.Text) = True And IsNumeric(TextBox2.Text) = True And IsNumeric(TextBox3.Text) = True And IsNumeric(TextBox4.Text) = True Then
If textbox1.text = textbox2.text Or textbox1.text = textbox3.text Or textbox1.text = textbox4.text Or textbox2.text = textbox3.text Or textbox2.text = textbox4.text Or textbox3.text = textbox4.text Then
MsgBox("數字不得重覆!!")
Else
For i = 1 To 6
If textbox1.text < textbox2.text Then
If textbox2.text < textbox3.text Then
If textbox3.text < textbox4.text Then
Exit For
Else
x = textbox4.text
textbox4.text = textbox3.text
textbox3.text = x
End If
Else
x = textbox3.text
textbox3.text = textbox2.text
textbox2.text = x
End If
Else
x = textbox2.text
textbox2.text = textbox1.text
textbox1.text = x
End If
Next
MsgBox(textbox1.text & "," & textbox2.text & "," & textbox3.text & "," & textbox4.text)
End If
Else
MsgBox("欄位不得空白或特殊符號!!請重新輸入!")
End If
End Sub
End Class
=====================================
我有修改了一下,請同學幫忙看是否有問題..
如果沒問題的話,做『由大到小』就把 < 換成 > 應該就可以了!!
對調一下
2008年12月8日 星期一
VB 倒星星
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i, j As Integer
Dim x As String
x = ""
For i = 5 To 1 Step -1
For j = 1 To i
x = x & "*"
Next
x = x & vbCrLf
Next
MsgBox(x)
End Sub
End Class
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i, j As Integer
Dim x As String
x = ""
For i = 5 To 1 Step -1
For j = 1 To i
x = x & "*"
Next
x = x & vbCrLf
Next
MsgBox(x)
End Sub
End Class
訂閱:
文章 (Atom)