2010年3月29日

異形叔叔的計算機組織之作業I

2.4 Why doesn't MIPS have a subtract immediate instruction?

參考答案:課本 Page.66 - Check yourself ,中文譯本 Page.61 - 自我測驗

大意為:

1.負常數在 C 和 Java 不常出現,因此他們不是常態,不需要提供特別支援
2.因為立即指令的放置立即值的欄位,可以放置負常數或正常數,立即加法加一個負數同等於立即減法減一個正數,所以不需要立即減法

*Mobile01 網友解答版:
http://www.mobile01.com/topicdetail.php?f=174&t=644124

2.6 Some computers have explicit instructions to extract an arbitrary field from a 32-bit register and to place it in the least significant bits of a register.

The figure below shows the desired operation:
Find the shortest sequence of MIPS instructions the extracts a field for the constant values i=5 and j=22 form register $t3 and places it in register $t0.(Hint : It can be done in two instructions.)

概念:
1. 數字帶入
2. 把 field 向左移到頂( 向左移9
3. 再將 field 推至底( 向右移15使 31 到 field 之間位置呈零,即完成

推移語法:課本 Page.71 - FIGURE2.10 ,中文譯本 Page.65 - -圖2.10

*向左位移:sll
*向右位移:srl

參考答案:

sll $t0,$t3,9
srl $t0,$t0,15

感謝哲睿熱情解題!

2.19 Iris and Julie are students in computer engineering who are learning about ASCII and Unicode character sets. Help them by spelling their names and your first name in both ASCII(using decimal notation) and Unicode(using hex notation and  the basic Latin character set.)

參考答案:課本 Page.91 - FIGURE 2.21 , 中文譯本 Page.86 - 圖2.21

ASCII 部分可以參照課本給的表
而 Unicode Latin 則是把 ASCII 碼轉成16位元,即完成
提供轉碼服務的網站(包含 ASCII 與 Unicode Latin):

Iris :
ASCII : "73,114,105,115"
Unicode : "49,72,69,73"

Julie :
ASCII : "74,117,108,105,101"

Unicode : "4A,75,6C,69,65"

以及你自己的 First name! 的 ASCII 與 Unicode !

*Remember 要手寫且要抄題目。
*題目僅獻給沒有課本的小孩。

沒有留言: