Download presentation
Presentation is loading. Please wait.
Published byDominick Singleton Modified over 9 years ago
1
Digital Computers and Information n Digital computers n Number representations n Arithmetic operations n Alphanumeric codes Read MK 3-26
2
1.2 - Jon Turner - 5/11/2015 What’s in a Computer? microprocessor monitor keyboard FPU CPU MMU Internal Cache External Cache Main Memory Peripheral Bus Interface Graphics Card Disk Controller Network Interface Microprocessor Central Processing Unit Floating Point Unit Memory Mgmt. Unit Internal Cache Memory Main Memory stores running programs and associated data typically 64-512 Mbytes Dynamic RAM
3
1.3 - Jon Turner - 5/11/2015 What’s in a Computer? microprocessor monitor keyboard FPU CPU MMU Internal Cache External Cache Main Memory Peripheral Bus Interface Graphics Card Disk Controller Network Interface Memory Bus External Cache small, fast memory stores recently used data Control movement of data between memory and I/O devices
4
1.4 - Jon Turner - 5/11/2015 What’s in a Computer? microprocessor monitor keyboard FPU CPU MMU Internal cache External Cache Main Memory Peripheral Bus Interface Graphics Card Disk Controller Network Interface Convert text & graphics to video Peripheral Bus Read/write data on proper physical location on disk Transfer data between external network & memory
5
1.5 - Jon Turner - 5/11/2015 What’s in a Chip? Intel 80286 Microprocessor ( www.micro.magnet.fsu.edu/chipshots) NEC/MIPS R4400 Microprocessor ( www.micro.magnet.fsu.edu/chipshots) n Photomicrographs made using colored filters.
6
1.6 - Jon Turner - 5/11/2015 Basic Processor & Memory n Memory stores programs and data. »organized as set of numbered storage slots »each storage slot (memory word) can hold a number »processor can read from or write to any word n Fetch & execute cycle »read word whose address is in Program Counter (PC) and increment PC »interpret stored value as instruction (decoding) »perform instruction using Accumulator (ACC) and Arithmetic & Logic Unit (ALU) 1050 PC ACC Instruction Decoder Arithmetic & Logic Unit Address Decode 11 0 1 2 3... ffff 21 -3 65 56 Processor Memory Address Data read/write
7
1.7 - Jon Turner - 5/11/2015 Instruction Set 0000halt - halt execution 0001negate - ACC := ACC 1xxximmediate load – if sign bit of xxx is 0 then ACC := 0xxx else ACC := fxxx 2xxxdirect load - ACC := M [ 0xxx ] 3xxxindirect load - ACC := M [ M [ 0xxx ]] 4xxxdirect store - M [ 0xxx ] := ACC 5xxxindirect store – M [ M [ 0xxx ]] := ACC 6xxxbranch - PC := 0xxx 7xxxbranch if zero - if ACC = 0 then PC := 0xxx 8xxxbranch if positive - if ACC > 0 then PC := 0xxx 9xxxbranch if negative - if ACC < 0 then PC := 0xxx axxxadd - ACC := ACC + M [ 0xxx ]
8
1.8 - Jon Turner - 5/11/2015 Simple Program n Add the values in locations 20-2f and write sum in 10. AddressInstructionComment 0000 (start)1000 (ACC := 0000)initialize sum 00014010 (M[0010] := ACC) 00021020 (ACC := 0020)initialize pointer 00034011 (M[0011] := ACC) 0004 (loop)1030 ( ACC := 0030)if pointer = 030, quit 00050001 (ACC := -ACC) 0006a011 (ACC :=ACC+M[0011]) 0007700f (if 0 goto 000f) 00083011 (M[M[0011]] := ACC) sum = sum + *pointer 0009a010 (ACC :=ACC+M[0010]) 000a4010 (M[0010] := ACC) 000b1001 (ACC := 0001)pointer = pointer + 1 000ca011 (ACC :=ACC+M[0011]) 000d4011 (M[011] := ACC) 000e6004 (goto 0004)goto loop 000f (end)0000 (halt)halt 0010Store sum here 0011Pointer to next value
9
1.9 - Jon Turner - 5/11/2015 Representing Information in Computers n Electronic computers represent information as voltage levels. n To make the computer hardware simple and reliable, computers represent information in binary form. »example: voltages greater than 3V are interpreted as representing one value (called “1”), voltages less than 2V are interpreted as representing another value (called “0”). n In principle, could use more voltage levels. »example: 0 to.75V represents “0”, 1 to 1.75V represents “1”, 2 to 2.75V represents “2”, and so forth. n In practice, this is rarely done. »requires more complex circuits »circuits are more susceptible to noise, hence less reliable
10
1.10 - Jon Turner - 5/11/2015 Noise in Computer Systems n Computers, like all electronic systems, are affected by noise. »noise has various sources (nearby signal changes, thermal vibrations of molecules in semiconductor materials,... ) »in computers, noise can cause binary signals to be misinterpreted n The noise margin is the amount of noise that a system can tolerate and still correctly identify a logic high or low. Undefined High Low Undefined High Low 5v 4v 3v 2v 1v 0v noise margin 1 V noise margin 3 V
11
1.11 - Jon Turner - 5/11/2015 Number Representation n Standard decimal number representation 243.83 = 2 10 2 + 4 10 1 + 3 10 0 + 8 10 1 + 3 10 2 n Generalization to base r A n...A 1 A 0.A 1...A m =A n r n +... + A 1 r 1 + A 0 r 0 + A 1 r 1 +... + A m r m n Binary number representation 110.01 = 1 2 2 + 1 2 1 + 0 2 0 + 0 2 1 + 1 2 2 n Converting binary numbers to decimal (easy). write binary expansion, replace powers of 2 with decimal values, and add up the values 110.01 = 1 2 2 + 1 2 1 + 0 2 0 + 0 2 1 + 1 2 2 = 4 + 2 + 1 4 = 6.25 Note: it helps to know your powers of 2 ( hint )
12
1.12 - Jon Turner - 5/11/2015 Decimal-Binary Conversion n Repeated division by 2 625/2 = 312 with remainder of 1 least significant bit 312/2 = 156 with remainder of 0 156/2 = 78 with remainder of 0 78/2 = 39 with remainder of 0 39/2 = 19 with remainder of 1 19/2 = 9 with remainder of 1 9/2 = 4 with remainder of 1 4/2 = 2 with remainder of 0 2/2 = 1 with remainder of 0 1/2 = 0 with remainder of 1 So, (625) 10 = (10 0111 0001) 2 n Works similarly for other number bases.
13
1.13 - Jon Turner - 5/11/2015 Octal and Hexadecimal n Octal (base 8) and hexadecimal (base 16) provide more convenient way for people to write binary numbers. »110101100010 = 110 101 100 010 = (6542) 8 1101 0110 0010 = (d62) 16 octal conversionhexadecimal conversion 000 = 00000 = 0 1000 = 8 001 = 10001 = 1 1001 = 9 010 = 20010 = 2 1010 = 10 = a 011 = 30011 = 3 1011 = 11 = b 100 = 40100 = 4 1100 = 12 = c 101 = 50101 = 5 1101 = 13 = d 110 = 60110 = 6 1110 = 14 = e 111 = 70111 = 7 1111 = 15 = f
14
1.14 - Jon Turner - 5/11/2015 Finite Data Representations n Computer hardware is generally designed to operate on words with a fixed number of bits (e.g. 16 bits). n Places a limit on the number of discrete values that can be stored in a single word (e.g. 2 16 ). If we use words to represent positive integers then with n bits, we can represent integers 0 up to 2 n 1 n Larger integers can be represented by multiple words. »computer hardware operates on single words »software must combine results from single word operations to produce desired result n Or, use floating point representation for large (and small) values; typically supported by computer hardware.
15
1.15 - Jon Turner - 5/11/2015 How Computers Add n Binary long addition similar to decimal long addition. decimal binary carry 1100111100 augend 2565 10110 addend 6754 11011 sum 9319110001 Binary addition algorithm - add a n 1... a 0 to b n 1... b 0 and put result in s n... s 0 c 0 =0// c i are carry bits for i = 0 to n 1 if one or three of a i, b i or c i are = 1 then s i = 1 else s i = 0 if at least two of a i, b i or c i are = 1, then c i +1 = 1 else c i +1 = 0 s n = c n
16
1.16 - Jon Turner - 5/11/2015 Modular and Signed Arithmetic n Computers use modular arithmetic in which values wrap around circularly. »to add A + B, start at position for A and then count clockwise B positions »modular arithmetic is just like “clock arithmetic” 0011+0110 =1001 1111+0011=0010 0000 0001 1100 0010 0011 1011 0100 1010 0101 1101 0110 0111 1111 1000 1110 1001 0 1 2 3 4 5 14 10 9 7 6 15 13 12 11 8 1111+0011=0010 0000 0001 1100 0010 0011 1011 0100 1010 0101 1101 0110 0111 1111 1000 1110 1001 0 1 2 3 4 5 -2 -6 -7 7 6 -3 -4 -5 -8 n Associating certain bit patterns with negative values yields signed arithmetic. n Negate a given value by flipping all bits and adding 1. n Must pay attention to overflow.
17
1.17 - Jon Turner - 5/11/2015 Representing Text n Computers use numbers to represent alphabetic characters, numerals and punctuation. n Most common encoding is ASCII (American Standard Code for Communication Interchange) »characters represented by 7 bit values »numerals start at (30) 16 »upper case letters start at (41) 16 »lower case letters start at (61) 16 »see Table 1-4 in Mano for details n Unicode uses 16 bits per character, allowing it to represent far more distinct characters.
18
1.18 - Jon Turner - 5/11/2015 Convert Numeric String to Internal Value n ASCII character codes for decimal integer stored in locations 20-24 with M.S.D. at location 20. Write internal value in location 1f. AddressInstructionComment 0000 (start)1000 (ACC := 0000)result = 0 0001401f (M[001f] := ACC) 00021020 (ACC := 0020)pointer = 020 0003401d (M[001d] := ACC) 0004 (loop)1025 (ACC := 0025)if pointer = 025, quit 00050001 (ACC := -ACC) 0006a01d (ACC := ACC + M[001d]) 00077015 (if 0 goto 0015) 0008100a (ACC := 000a)result = 10 * result 0009b01f (ACC := ACC*M[001f]) New multiply inst. 000a401f (M[001f] := ACC)
19
1.19 - Jon Turner - 5/11/2015 Convert Numeric String (continued) AddressInstructionComment 000b 1fd0 (ACC := -30) result = result 000c 401e (M[001e] := ACC) + (*pointer-‘0’) 000d 301d (ACC := M[M[001d]]) 000e a01e ( ACC += ACC+ M[001e]) 000f a01f ( ACC += ACC+ M[001f]) 0010 401f (M[001f] := ACC) 0011 1001 (ACC := 0001) pointer = pointer + 1 0012 a01d (ACC := ACC+M[001d]) 0013 401d (M[001d] := ACC) 0014 6004 (goto 0004)goto loop 0015 (end)0000 (halt)halt.... 001dPointer to next char 001eTemporary value 001fStore result here 0020ASCII digits
20
1.20 - Jon Turner - 5/11/2015 Convert Internal Value to Numeric String Write ASCII character codes for value in location 1f into words 20..24 with L.S.D. in word 20. pointer = 20 loopif pointer = 25 then quit *pointer = (value modulo 10) + ‘0’ value = value / 10 pointer = pointer + 1 goto loop n Exercise: write corresponding machine program; assume two new instructions cxxx divide value in accumulator by value in location xxx and leave quotient in accumulator dxxx divide by value in xxx & put remainder in ACC
21
1.21 - Jon Turner - 5/11/2015 Another Look at Basic Computer n Program Counter (PC) stores address of next instruction. n Instruction Register & Decoder (IREG) stores current instruction. n Indirect Address Register (IAR) stores indirect addresses. n Accumulator (ACC) stores arithmetic operands and results. n Arithmetic & Logic Unit (ALU) implements arithmetic functions. n Controller coordinates actions of other components. n Data & Address Buses carry data between components. Controller PC Data Bus Address Bus Memory 0000 0001 0002 0003 0004 0005 0006 0007 0008 0009 000a ffff... IREGIARACC read/write ALU
22
1.22 - Jon Turner - 5/11/2015 Execution of a Computer Program monitored signals waveforms & buses time axis system clock reset (initialization) program counter, instruction register, accumulator,...
23
1.23 - Jon Turner - 5/11/2015 Execution of a Computer Program reset period execute first instruction - mload fetch first instruction fetch second instruction execute second instruction – dload
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.