版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、Chapter Two Data Numbering & Character Encoding System in MicrocomputerPrinciples of MicrocomputersChapter TwoChapter TwoData Numbering and Character Encoding Data Numbering and Character Encoding System in Microcomputer System in Microcomputer 計(jì)算機(jī)中的數(shù)制和編碼計(jì)算機(jī)中的數(shù)制和編碼3 3Chapter Two Data Numbering &
2、amp; Character Encoding System in MicrocomputerPrinciples of Microcomputers2.3 信信 息息 的的 編編 碼碼 Chapter Two Data Numbering & Character Encoding System in MicrocomputerPrinciples of MicrocomputersChapter Two Data Numbering & Character Encoding System in MicrocomputerPrinciples of Microcomputers
3、 4位二進(jìn)制數(shù)碼有16種組合(00001111),原那么上可任選其中的10個(gè)來(lái)分別代表十進(jìn)制中09這10個(gè)數(shù)字。但為了便于記憶,最常用的是8421 BCD碼,這種編碼從00001111這16種組合中選擇前10個(gè)即00001001來(lái)分別代表十進(jìn)制數(shù)碼09,8、4、2、1分別是這種編碼從高位到低位每位的權(quán)值。BCD碼有兩種方式,即緊縮型BCD碼和非緊縮型BCD碼。 Chapter Two Data Numbering & Character Encoding System in MicrocomputerPrinciples of MicrocomputersChapter Two Dat
4、a Numbering & Character Encoding System in MicrocomputerPrinciples of Microcomputers表表2.2 8421 BCD 碼部分編碼表碼部分編碼表 十進(jìn)制數(shù)緊縮型BCD碼非緊縮型BCD碼12391011192021000000010000001000000011000010010001000000010001000110010010000000100001000000010000001000000011 0000100100000001 0000000000000001 00000001 00000001 00
5、00100100000010 0000000000000010 00000001Chapter Two Data Numbering & Character Encoding System in MicrocomputerPrinciples of Microcomputers 需求闡明的是,雖然BCD碼可以簡(jiǎn)化人機(jī)聯(lián)絡(luò),但它比純二進(jìn)制編碼效率低,對(duì)同一個(gè)給定的十進(jìn)制數(shù),用BCD碼表示時(shí)需求的位數(shù)比用純二進(jìn)制碼多,而且用BCD碼進(jìn)展運(yùn)算所花的時(shí)間也要更多,計(jì)算過(guò)程更復(fù)雜,由于BCD碼是將每個(gè)十進(jìn)制數(shù)用一組4位二進(jìn)制數(shù)來(lái)表示,假設(shè)將這種BCD碼送計(jì)算機(jī)進(jìn)展運(yùn)算,由于計(jì)算機(jī)總是將數(shù)當(dāng)作二進(jìn)
6、制數(shù)來(lái)運(yùn)算,所以結(jié)果能夠出錯(cuò),因此需求對(duì)計(jì)算結(jié)果進(jìn)展必要的修正,才干使結(jié)果為正確的BCD碼方式。詳見(jiàn)本小節(jié)例2.17。 Chapter Two Data Numbering & Character Encoding System in MicrocomputerPrinciples of Microcomputers例2.15 十進(jìn)制數(shù)與BCD數(shù)相互轉(zhuǎn)換。 將十進(jìn)制數(shù)69.81轉(zhuǎn)換為緊縮型BCD數(shù): 69.81=(0110 1001.1000 0001)BCD 將BCD數(shù)1000 1001.0110 1001轉(zhuǎn)換為十進(jìn)制數(shù):(1000 1001.0110 1001)BCD=89.69
7、Chapter Two Data Numbering & Character Encoding System in MicrocomputerPrinciples of Microcomputers 例2.16 設(shè)有變量x等于10010110B,當(dāng)該變量分別為無(wú)符號(hào)數(shù)、原碼、補(bǔ)碼、緊縮型BCD碼時(shí),試分別計(jì)算變量x所代表的數(shù)值大小。解 無(wú)符號(hào)數(shù):x=10010110B=127+026+025+124+023+122+121+020=150原碼:x原=10010110B x= -026+025+124+023+122+121+020= -22補(bǔ)碼:x補(bǔ)=10010110B x原=x補(bǔ)補(bǔ)=
8、11101010B x= -126+125+024+123+022+121+020= -106 BCD碼:xBCD=10010110B x=96Chapter Two Data Numbering & Character Encoding System in MicrocomputerPrinciples of Microcomputers 例2.17 (BCD碼運(yùn)算時(shí)的修正問(wèn)題)用BCD碼求38+49。 解 0011 1000 38的BCD碼+) 0100 1001 49的BCD碼 1000 0001 81的BCD碼 計(jì)算結(jié)果1000 0001是81的BCD數(shù),而正確結(jié)果應(yīng)為87的B
9、CD數(shù)1000 0111,因此結(jié)果是錯(cuò)誤的。其緣由是,十進(jìn)制數(shù)相加應(yīng)該是“逢十進(jìn)一,而計(jì)算機(jī)按二進(jìn)制數(shù)運(yùn)算,每4位為一組,低4位向高4位進(jìn)位與十六進(jìn)制數(shù)低位向高位進(jìn)位的情況相當(dāng),是“逢十六進(jìn)一,所以當(dāng)相加結(jié)果超越9時(shí)將比正確結(jié)果少6,因此結(jié)果出錯(cuò)。處理方法是對(duì)二進(jìn)制加法運(yùn)算結(jié)果采用“加6修正,從而將二進(jìn)制加法運(yùn)算的結(jié)果修正為BCD碼加法運(yùn)算結(jié)果。Chapter Two Data Numbering & Character Encoding System in MicrocomputerPrinciples of Microcomputers BCD數(shù)相加時(shí),對(duì)二進(jìn)制加法運(yùn)算結(jié)果修正的規(guī)
10、那么如下: 假設(shè)兩個(gè)對(duì)應(yīng)位BCD數(shù)相加的結(jié)果向高位無(wú)進(jìn)位,且結(jié)果小于或等于9,那么該位不需求修正;假設(shè)得到的結(jié)果大于9而小于16,那么該位需求加6修正。 假設(shè)兩個(gè)對(duì)應(yīng)位BCD數(shù)相加的結(jié)果向高位有進(jìn)位(結(jié)果大于或等于16),那么該位需求進(jìn)展加6修正。 因此,兩個(gè)BCD數(shù)進(jìn)展運(yùn)算時(shí),首先按二進(jìn)制數(shù)進(jìn)展運(yùn)算,然后必需用相應(yīng)的調(diào)整指令進(jìn)展調(diào)整,從而得到正確的BCD碼結(jié)果。有關(guān)BCD運(yùn)算結(jié)果的調(diào)整指令將在第4章“80 x86指令系統(tǒng)中引見(jiàn)。 Chapter Two Data Numbering & Character Encoding System in MicrocomputerPrincip
11、les of Microcomputers2.4 數(shù)的定點(diǎn)與浮點(diǎn)表示法數(shù)的定點(diǎn)與浮點(diǎn)表示法 符號(hào)位數(shù)值位小數(shù)點(diǎn)(a)符號(hào)位數(shù)值位小數(shù)點(diǎn)(b)圖2.1 定點(diǎn)數(shù)的兩種表示方法(a) 純小數(shù)方式;(b) 純整數(shù)方式 Chapter Two Data Numbering & Character Encoding System in MicrocomputerPrinciples of Microcomputers 設(shè)用一個(gè)n+1位字來(lái)表示一個(gè)數(shù)x,其中一位表示符號(hào)位(0表示正,1表示負(fù)),其他n位為數(shù)值位。對(duì)于純小數(shù)表示法,所能表示的數(shù)x (原碼表示,下同)的范圍為:-(1-2-n)x1-2-
12、n (2.4.1) 它能表示的數(shù)的最大絕對(duì)值為1-2-n,最小絕對(duì)值為2-n。 對(duì)于純整數(shù)表示法,所能表示的數(shù)x的范圍為:-(2n-1)x2n -1 (2.4.2)它能表示的數(shù)的最大絕對(duì)值為2n-1,最小絕對(duì)值為1。 Chapter Two Data Numbering & Character Encoding System in MicrocomputerPrinciples of Microcomputers2.4.2 浮點(diǎn)表示浮點(diǎn)表示 所謂浮點(diǎn)表示法,就是小數(shù)點(diǎn)在數(shù)中的位置是浮動(dòng)的。所謂浮點(diǎn)表示法,就是小數(shù)點(diǎn)在數(shù)中的位置是浮動(dòng)的。 恣意一個(gè)二進(jìn)制數(shù)恣意一個(gè)二進(jìn)制數(shù)x總可以寫(xiě)成如下
13、方式:總可以寫(xiě)成如下方式: (2.4.3)其中,其中,d稱(chēng)為尾數(shù),是二進(jìn)制純小數(shù),指明數(shù)的全部有效數(shù)字,前稱(chēng)為尾數(shù),是二進(jìn)制純小數(shù),指明數(shù)的全部有效數(shù)字,前面的符號(hào)稱(chēng)為數(shù)符,表示數(shù)的符號(hào),該位為面的符號(hào)稱(chēng)為數(shù)符,表示數(shù)的符號(hào),該位為0,闡明該浮點(diǎn)數(shù)為正,闡明該浮點(diǎn)數(shù)為正,該位為該位為1,闡明該浮點(diǎn)數(shù)為負(fù);,闡明該浮點(diǎn)數(shù)為負(fù);p稱(chēng)為階碼,它前面的符號(hào)稱(chēng)為階符,稱(chēng)為階碼,它前面的符號(hào)稱(chēng)為階符,階碼為正時(shí),用階碼為正時(shí),用0表示,階碼為負(fù)時(shí),用表示,階碼為負(fù)時(shí),用1表示。表示。 階符階碼(p)數(shù)符尾數(shù)d1 位m位1位n位Chapter Two Data Numbering & Charact
14、er Encoding System in MicrocomputerPrinciples of Microcomputers 可以看出,將尾數(shù)d的小數(shù)點(diǎn)向右(階碼p為正時(shí))或向左(階碼p為負(fù)時(shí))挪動(dòng)p位,即可得到該浮點(diǎn)數(shù)表示的數(shù)值x。階碼p指明小數(shù)點(diǎn)的位置,小數(shù)點(diǎn)隨著階碼的大小和正負(fù)而浮動(dòng),因此把這種數(shù)稱(chēng)為浮點(diǎn)數(shù)。 設(shè)階碼的位數(shù)為m位,尾數(shù)的位數(shù)為n位,那么該浮點(diǎn)數(shù)表示的數(shù)值范圍為:(2.4.4) 在字長(zhǎng)一樣的情況下,浮點(diǎn)數(shù)能表示的數(shù)值范圍比定點(diǎn)數(shù)大得多,且精度高,但浮點(diǎn)運(yùn)算規(guī)那么復(fù)雜。)12()12(2)21 (|22mmnnxChapter Two Data Numbering &
15、; Character Encoding System in MicrocomputerPrinciples of MicrocomputersSummarySummary Most modern computer systems use the binary numbering system to represent values. Since binary values are somewhat unwieldy, well often use the hexadecimal representation in our assembly programs.A single hexadeci
16、mal digit consumes four binary digits (bits), and we call a group of four bits a nibble. The 80 x86 works best with groups of bits which are eight, 16, or 32 bits long. We call objects of these sizes bytes, words, and double words, respectively. In order to talk about specific bits within a nibble,
17、byte, word, double word, or other structure, well number the bits starting at zero (for the least significant bit) on up to n-1(where n is the number of bits in the object)Chapter Two Data Numbering & Character Encoding System in MicrocomputerPrinciples of MicrocomputersSummarySummary There are
18、many operations we can perform on binary values including normal arithmetic (+, -, *, and /) and the logical operations (AND, OR, XOR, NOT, Shift Left, Shift Right, Rotate Left, and Rotate Right). Logical AND, OR, XOR, and NOT are typically defined for single bit operations. We can extend these to n
19、 bits by performing bitwise operations. The shifts and rotates are always defined for a fixed length string of bits. There are two types of integer values which we can represent with binary strings on the 80 x86: unsigned integers and signed integers. The 80 x86 represents unsigned integers using th
20、e standard binary format. It represents signed integers using the twos complement format. Chapter Two Data Numbering & Character Encoding System in MicrocomputerPrinciples of MicrocomputersSummarySummary Character data is probably the most common data type encountered besides integer values. The
21、 IBM PC and compatibles use a variant of the ASCII character set the extended IBM/ASCII character set. The first 128 of these characters are the standard ASCII characters, 128 are special characters created by IBM for international languages, mathematics, and line drawing. Since the use of the ASCII
22、 character set is so common in modern programs, familiarity with this character set is essential.Chapter Two Data Numbering & Character Encoding System in MicrocomputerPrinciples of Microcomputers Questions Questions1) Convert the following decimal values to binary:a) 128 b) 4096c) 256 d) 65536
23、e) 254 f) 8882) Convert the following binary values to decimal:a) 1001 1001 b) 1001 1101c) 1100 0011d) 0000 1001 e)1111 1110Chapter Two Data Numbering & Character Encoding System in MicrocomputerPrinciples of MicrocomputersQuestionsQuestions3) Convert the binary values in problem 2 to hexadecima
24、l.4) Convert the following hexadecimal values to binary:a) 0ABCD b) 1024 c) 0DEAD d) 0ADD e) 0BEEFPerform the following hex computations (leave the result in hex):5) 1234 +98766) 0FFF - 0F347) 100 - 18) 0FFE - 19) What is the importance of a nibble?10) How many hexadecimal digits in:a) a byte b) a w
25、ord c) a double wordChapter Two Data Numbering & Character Encoding System in MicrocomputerPrinciples of MicrocomputersQuestionsQuestions11) How many bits in a:a) nibble b) byte c) word d) double word12) Which bit (number) is the H.O. bit in a:a) nibble b) byte c) word d) double word13) What cha
26、racter do we use as a suffix for hexadecimal numbers? Binary numbers? Decimalnumbers?14) Assuming a 16-bit twos complement format, determine which of the values in question 4 are positive and which are negative.15) Sign extend all of the values in question two to sixteen bits. Provide your answer in
27、 hex.Chapter Two Data Numbering & Character Encoding System in MicrocomputerPrinciples of MicrocomputersQuestionsQuestions16) Perform the bitwise AND operation on the following pairs of hexadecimal values. Present your answer in hex. (Hint: convert hex values to binary, do the operation, then co
28、nvert back to hex).a) 0FF00, 0FF0 b) 0F00F, 1234 c) 4321, 1234 d) 2341, 3241 e) 0FFFF, 0EDCB17) Perform the logical OR operation on the above pairs of numbers.18) Perform the logical XOR operation on the above pairs of numbers.19) Perform the logical NOT operation on all the values in question four.
29、 Assume all values are 16 bits.Chapter Two Data Numbering & Character Encoding System in MicrocomputerPrinciples of MicrocomputersQuestionsQuestions20) Perform the twos complement operation on all the values in question four. Assume 16 bit values.21) Sign extend the following hexadecimal values
30、from eight to sixteen bits. Present your answer in hex.a) FF b) 82 c) 12 d) 56 e) 98f) BF g) 0F h) 78 i) 7F j) F722) Sign contract the following values from sixteen bits to eight bits. If you cannot perform the operation, explain why.a) FF00 b) FF12 c) FFF0 d) 12 e) 80f) FFFF g) FF88 h) FF7F i) 7F j
31、) 223) Sign extend the 16-bit values in question 22 to 32 bits.24) Assuming the values in question 22 are 16-bit values, perform the left shift operation on them.25) Assuming the values in question 22 are 16-bit values, perform the right shift operation on them.Chapter Two Data Numbering & Chara
32、cter Encoding System in MicrocomputerPrinciples of MicrocomputersQuestionsQuestions26) Assuming the values in question 22 are 16-bit values, perform the rotate left operation on them.27) Assuming the values in question 22 are 16-bit values, perform the rotate right operation on them.28) Convert the
33、following dates to the packed format described in this chapter (see “Bit Fields and Packed Data on page 28). Present your values as a 16-bit hex number.a) 1/1/92 b) 2/4/56 c) 6/19/60 d) 6/16/86 e) 1/1/9929) Describe how to use the shift and logical operations to extract the day field from thepacked
34、date record in question 28. That is, wind up with a 16-bit integer value in the range 0.31.30) Suppose you have a value in the range 0.9. Explain how you could convert it to an ASCII character using the basic logical operations.Chapter Two Data Numbering & Character Encoding System in MicrocomputerPrinciples of Microcomputers本章作業(yè)本章作業(yè)1. Convert the following decimal values to binary: a) 128 b) 4096 c) 256 d) 655362. Convert the following binary values to decimal: a) 1001 1001 b) 1001 11013. Convert the following hexadecimal values to binary: a) 0ABC
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 聘用合同補(bǔ)充協(xié)議的簽訂與履行期限
- 立式冷熱型直飲水機(jī)購(gòu)銷(xiāo)合同
- 建筑施工監(jiān)理合同協(xié)議
- 墻繪施工合同示范
- 場(chǎng)地服務(wù)合同協(xié)議書(shū)范本規(guī)范
- 貸款合同續(xù)簽注意事項(xiàng)
- 房屋裝修及維護(hù)服務(wù)合同
- 農(nóng)產(chǎn)品購(gòu)買(mǎi)合同心得
- 房屋買(mǎi)賣(mài)合同見(jiàn)證律師服務(wù)解析
- 房屋拆遷與買(mǎi)賣(mài)合同關(guān)系
- 數(shù)據(jù)分析服務(wù)合同三篇
- 血透室安全隱患
- 《中國(guó)園林發(fā)展》課件
- 菏澤學(xué)院教育科學(xué)研究方法(專(zhuān)升本)復(fù)習(xí)題
- 小學(xué)科技節(jié)活動(dòng)總結(jié)15篇
- 船運(yùn)居間協(xié)議合同范例
- 質(zhì)控競(jìng)聘課件
- 2024-2025學(xué)年統(tǒng)編版道德與法治三年級(jí)上冊(cè) 期末測(cè)試卷(含答案)
- 教育學(xué)原理項(xiàng)賢明第九章教師與學(xué)生
- 嚴(yán)禁在學(xué)校組織宗教活動(dòng)
- 2023-2024學(xué)年廣東省湛江市赤坎區(qū)某中學(xué)七年級(jí)上學(xué)期期末數(shù)學(xué)試卷及參考答案
評(píng)論
0/150
提交評(píng)論