发新话题
打印

计算机代码

计算机代码

COMPUTER CODES      Although the capacity of their storage locations can vary,every computer stores numbers,letters,and other characters in a coded form.  $ f& a# V6 O& r2 q2 _
  Every character in storage is represented by a string of 0s and 1s—the only digits found in the binary numbering system.  Let’s see how it’s possible to use just two digits to represent any character.  
9 r- y; w' @$ g" l- b/ BMost computers use a coded version of true binary to represent decimal numbers.  
4 b' S* [/ }2 xAlthough many coding schemes have been developed over the years,the most popular of these use a binary coded decimal(BCD)approach.# O( E  e' r. |, L5 d
  The BCD Approach.
5 _7 u( |% y7 f3 B% V- E  With BCD,it’s possible to convert each decimal number into its binary equivalent rather than convert the entire decimal value into a pure binary form.
) X& M3 ]$ q4 Z7 F. O' m/ O. H  The BCD equivalent of each possible symbol is shown in Fig.1-3.
( P/ `; o2 @! x" _+ H+ F7 J  Since 8 and 9 require 4 bits,all decimal digits are presented in BCD by 4 bits.  1 {) n: D7 }! R7 Z; t
  You’ve just seen that 202 is equal to 1100 1010 in a pure binary form.      " P+ a% J) x  E+ ~/ ~: ~
  Converting 202 into BCD,however,produces the following result:202(10)in BCD=0010 0000 0010 or 0010 0000 0010% }6 j1 u& j, j3 S. b# ~: Z( S& T2 d

7 z$ W. l. a* z8 B' a6 _+ I  Six-bit BCD Code.  6 F# r% n0 r+ c5 ~9 c# Z
  Instead of using 4 bits with only 16 possible characters,computer designers commonly use 6,7,8 bits to represent characters in alphanumeric versions of BCD.  
9 G7 ?2 \+ v& o) @! h7 }9 j7 u# ^" ^  In the 6-bit code,the four BCD numeric place positions(1,2,4,and 8)are retained,but two additional zone positions are included(Fig. 1-4(a))." ]% m  z; N. h9 Q
  With 6 bits,it’s possible to represent 64 different characters(26)." ~) i( M( o! n
  This is a sufficient number to code the decimal digits(10),capital letters(26),and other special characters and punctuation marks(28)./ H( T& n* x* c: W8 d
  Fig. 1-4(b)shows you how a few of the 64 possible characters are represented in a standard 6-bit BCD code.  
9 n# C* e) u) f9 V0 ^  Seven and Eight-Bit Codes.  ! I3 y8 r, o( {5 \! X
  Since 64 possible bit combinations isn’t sufficient to provide decimal numbers(10),lower-case letters(26),capital letters(26),and a large number of other characters (28),designers have extended the 6-bit BCD code to 7 and 8 bits., D0 B/ V9 ?6 p& S
With 7 bits,it’s possible to provide 128 different arrangements(27);with 8 bits,256 variations are possible(28).
1 d; ^4 Z4 `* ^2 G9 \" t7 @In addition to the four numeric place positions,there are three zone bit positions in a 7-bit code,and four zone bit positions in an 8-bit code.
: X3 t  i7 ~6 q4 N0 E8 k! i  The 7-bit American Standard Code for Information Interchange(ASCII)is widely used in data communications work and is by far the most popular code used to represent data internally in personal computers.
' \  Q) }$ a0 E) l8 p5 y% i( DThe ASCII format and the coding used to represent selected characters are shown in Fig. 1-5.
3 Y) V/ u: @" v( b; A( `) _These are other two 8-bit codes in common use.  
0 r) Z1 b8 b3 \" r& z! m1 QOne is the Extended Binary Coded Decimal Interchange Code(EBCDIC).  
, H( }5 X+ a2 _This code is used in IBM mainframe models and in similar machines produced by other manufactures.  : R( s7 ~# O$ T$ n7 e7 ]
The other 8-bit code is ASCII-8,an 8-bit version of ASCII that is frequently used in the larger machines produced by some vendors.  
" @2 A. k  J; |/ F! q6 O+ uFig. 1-6 presents the 8-bit format and shows how selected characters are represented in these 8-bit codes. The main difference is in the selection of bit patterns to use in the zone positions.  : f( s# L7 t( w1 s+ s0 V: |" O8 E
. m% G  g( o0 D
$ u, K% y1 W- D) O. V1 G
  计算机代码
; S  }8 c, ~' G% W! r  尽管计算机存储单元的容量可大可小,但是每台计算机都是以代码形式存储数、字母和其他字符的。
# E9 R% T& B. e+ x9 G/ `     存储器中的每个字符都用0、1(二进制编码系统中仅有的两个数字)串表示。下面让我们看看如何只用两个数字来表示任何字符。
+ f) l  E' s2 [( J- A     大多数计算机用准确的二进制编码方法表示十进制数。
1 e; @0 T# R- @2 R% F; D, [" s     多年来研制了许多编码方案,其中最流行的是二进制编码的十进制(BCD)方案。0 \9 L# D" B+ d) l1 i
     BCD方案:用BCD码,可以将十进制数的每一位转换成相等的二进制数,而不是将整个十进制数的值转换成纯二进制数的形式。各十进制数位对应的BCD码如图1-3所示。因为8和9需要4位二进制数表示,所以,所有十进制数位均用4位BCD码表示。众所周知,用纯二进制数表示202等于11001010,但是将202转换成BCD码,结果如下:202(10)的BCD码 = 0010 0000 0010或001000000010。* _  U( p, x5 }( T
    6位BCD码。计算机设计者普遍采用6位、7位或8位BCD字母数字型字符来代替只有16种可能字符的4位BCD码。在6位BCD码中,4位BCD数字位(1,2,4,8)仍保留,但是,包含了两个附加的标志位,如图1-4(a)所示。用6位二进制数可以表示64个不同字符(26)。这对十进制数字(10个)、大写字母(26个)及其他特殊字符和标点符号(28个)进行编码已经够用。其中,几个对应的标准6位BCD码字符如图1-4(b)所示。
  }! l; _3 f8 Q& B5 `" t4 G# `0 d& x7 O   7位和8位编码。因为64种可能的位排列仍不能满足十进制数(10个)、小写字母(26个)、大写字母(26个)和大量的其他字符(28个)编码的需要,所以设计者将6位BCD码扩充到7位和8位。7位二进制数可以提供128种不同的排列(27);而8位二进制数可以有256种排列(28)。除了4位数字位之外,在7位编码中有3个标志位,在8位编码中则有4个标志位。7位美国信息交换用标准代码(ASCII)广泛地用于数据通信,而且是目前个人计算机内部数据表示中最为流行的代码。ASCII码的格式及所选字符的编码如图1-5所示。8 V$ n5 f9 d8 ~- {0 @1 w( `
     还有另外两种普遍使用的8位编码。一种是扩展的二-十进制交换码(EBCDIC),该编码用于IBM大型计算机及其他厂家生产的类似机器中;另一种8位编码是ASCII-8,是ASCII代码8位格式,常用于一些厂商生产的较大机器中。8位编码的格式及如何表示所选字符如图1-6所示。这两种编码的主要区别在于标志位模式的选择。0 _$ x4 w3 ~. E
Detecting Code Errors.  
. l) R* \* r) z  Computers are very reliable,but they’re not infallible.  5 ^6 X: n/ d8 N- M2 p; J7 N' V
If just one bit in a string of 6,7,or 8 bits is lost during data input,processing,or output operations,an incorrect character code will be created.  0 p" _3 ]1 Z" w5 Z7 m5 d
  Such an error can be caused by dust particles on storage media,by improper humidity levels near the computer,or by many other factors.
' T) W) r3 q: R/ J( B# v  Q  Fortunately,however,computer designers have developed a method for detecting such errors by adding an extra check bit or parity bit to each 6,7,or 8-bit character represented in storage.  3 B& ?# p% G& C
Thus,as you can see in Fig. 1-7,a total of 7,8,or 9 bits may actually be stored.  2 ~$ z- s! M- l* a
The designers of a particular computer model may then use the check bit to make sure that every valid character code will always have an even number of 1 bits.  , c% [+ w, ]) X# Q
  The 6-bit coding used to represent selected characters was presented earlier in Fig.1-4.  $ s: f8 H6 O# n: Q
Several of these characters have been reproduced in Fig.1-8.  1 d6 `7 r& ?& G1 k' B
0 Z% J5 j* b; s  i, `  p7 f
  You’ll notice that if the basic code for a character such as 1,2,or A requires an odd number of 1 bits,an additional 1 bit is added in the check-bit location so that there will always be an even number of such bits.. q' y+ _# X% L
  This is an example of an even-parity format,but other computers use the check bit to produce an odd parity.: \5 B2 M' r. g& A' O
  Since every valid character in a computer that uses even parity must always have an even number of 1 bits,circuits for parity,checking are built into the computer to constantly monitor the data moving through the system.! G8 p, L' r1 i
  The computer operator is notified if a bit is lost and a parity error is detected.Of course,parity checking will only detect coding errors.
3 k2 P2 \6 {1 D4 w& W3 R  It cannot signal the fact that incorrect data have been entered into the system if the data are properly coded.$ Z- [5 q; l; c. ~( Z5 L
  代码检错。
4 n/ l, J0 b7 {' l5 O! b  计算机可靠性高,但并非不会出错。在数据输入、处理或输出*作中,6位、7位或8位二进制数串即使仅有1位丢失,也会产生错误的字符代码。这样的错误可由存储介质上的灰尘微粒、计算机附近的湿度不适宜或许多其他因素造成。' m5 Q' L4 _8 \: k1 k6 b+ f
  不过幸运的是计算机设计者已研制了一种检测这种错误的方法,这就是对在存储器中表示的每个6位、7位或8位字符增加一个附加的检查位或奇偶检验位。这样,正如你在图1-7中所看到的,实际存储的可以是7位、8位或9位。于是,特定计算机的设计者可使用校验位来保证每个合法字符的代码总保持偶数个“1”。前面图1-4所示的是所选字符的6位编码。其中一些字符在图1-8中重新表示。注意,如果像1、2或A这样的字符的基本代码有奇数个“l”,那么就要在检验位上加一个“l”,使得代码总保持偶数个“l”。这是一个偶检验的例子,而其他计算机也可使用检验位生成奇检验。因为计算机中使用偶检验时,合法字符总有偶数个“1”,所以计算机中装入了奇偶检验检测电路,经常监测系统中移动的数据。如果有位丢失,就会检测到奇偶检验错,并通知计算机*作人员。当然,奇偶检验只能检测编码. P  A1 Y( [& Y, u, k0 z
错。它不能告知数据编码正确但输入数据本身出错的情况。
IT动力源欢迎您

TOP

NOTES7 L) ?) }" N, s# Z
[1]  短语by far修饰比较级与最高级,强调数量、程度等,意为“……得多,最……”,6 t, `1 k9 m5 g6 c
这是一个用and 连接的并列句。0 D7 S, W8 W! X7 a
[2] to make sure是不定式短语作目的状语,其后的that引导的是make的宾语从句。 KEYWORDS
" t3 X0 A" {4 ]/ j4 f8 g& j
Binary Coded Decimal(BCD)   二进制编码的十进制,二-十进制# g- t+ s1 b' Y( d' p
ASCII           美国信息交换用标准代码
* ?# M* {: \9 R7 }EBCDIC     扩展的二-十进制交换码
5 t0 k, x, m& [+ t" v+ @even-parity               偶检验
: k% x, v; t  o4 w" t* U0 D6 G/ K0 N, Todd-parity                 奇检验% e; W9 X9 N; b1 _0 Z
parity checking        奇偶检验
! L! z9 V) m/ V9 N6 ]EXERCISES
6 u5 X& R/ N- I8 \, ^1 S
1.True/False.! n- i/ y! z& Q# @( a
(1)______  The possible symbols in the binary numbering system are 0 to 9.
, x) j5 k1 f! L% w) W; S; @(2)______The decimal value of 16 is represented in 4 bit BCD as 00010101.
, H* N, Q, U+ O. g+ I: l. n(3)______Alphanumeric versions of BCD commonly use 7,or 8 bits to represent characters.
/ o! \$ g( z5 J* \$ w(4)______ A 6 bit alphanumeric code can represent 128 different characters.( y+ {: a0 W# z# {& q; Q
(5)______There are four 8 bit codes in current use.
, }* I: A7 p( Z' j  ~(6)______ Each 8 bit unit used to code data is called a byte.
5 c. a( {! z) g2 g! `1 d) Y(7)______ Eight bit codes are limited to representing 128 different characters.
0 V, D; H6 c* B* \$ R: s5 R7 w(8)______ An extra check(or parity)bit is often added to each 7,or 8 bit character represented in storage so that it will be possible to detect coding errors that may occur.' ^6 p7 Q- V3 h. Z, i5 T6 T
(9)______ The digits that can be found in the binary numbering system are only 0s
- M4 u1 T. P6 o& X4 Land 1s.
% `: N5 [' `+ X) x9 \# n(10______ Using BCD we can convert the entire decimal value into a pure binary , G3 h5 \0 d3 J$ M; m
form.
5 v% @6 F; U) u2 S2.Fill in the blanks with appropriate words or phrases found behind this exercise./ }0 `: \) @' h' g9 A7 a
(1)Every computer stores numbers,letters and characters in a ______  form.$ ^, N7 }: U$ o
(2)The abbreviation BCB is derived from its full name______.
2 S/ j# d2 |! C: m& D(3)Using BCD we can convert each decimal number into its binary______.
. l3 x  t& p) G/ P% |8 X" F(4)In addition to four numeric place positions in an 8-bit code there are another four      
) {8 h- R; y: o/ k: S( f5 j, a       ______positions.3 D) X" K& P+ D+ ]9 N+ O# z
(5)The most popular code used to represent data internally in personal computer is ______.5 \: c3 o( R" f! I, X
(6)The main difference between EBCDIC and ASCII-8 is______ positions.
2 r" N" i% L. Z# l4 p- _2 I(7)Parity checking has two types,they are ______.
; x5 V' O* h2 }8 k# d# o8 Y0 J(8)Any character can be represented by using just______of 0 and 1.( _( `% O8 P. P. q1 {' f
   a.equivalent
8 d4 Q0 O6 x) V! w   b.even-parity and odd-parity
# ?- b/ T" }! k) R' G' Z$ o8 l; M! S   c.ASCII- T7 Y& H% A0 L% e. }$ G
   d.coded: v5 }+ a4 C) |# w
   e.two digits" \( }3 s: {. A6 z& `" ?& Q& E* G
   f.patterns of zone- U  j% B) [3 q; [5 }
   g.zone bit' W* X; p* B) {
   h.binary coded decimal: ?" I4 z9 Z6 f- P$ M2 ]1 ?
1.(1)f  (2)f  (3)t  (4)f(5)f  (6)t  (7)f (8)t(9)t  (10)f6 h: e' X/ d) k! ?1 {5 U
2.(1)d  (2)h   (3)a   (4)g(5)c   (6)f  (7)b   (8)e
IT动力源欢迎您

TOP

发新话题