Download presentation

Presentation is loading. Please wait.

Published byDominick Singleton Modified about 1 year 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 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 Microprocessor ( NEC/MIPS R4400 Microprocessor ( 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 ffff 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 (M[0010] := ACC) (ACC := 0020)initialize pointer (M[0011] := ACC) 0004 (loop)1030 ( ACC := 0030)if pointer = 030, quit (ACC := -ACC) 0006a011 (ACC :=ACC+M[0011]) f (if 0 goto 000f) (M[M[0011]] := ACC) sum = sum + *pointer 0009a010 (ACC :=ACC+M[0010]) 000a4010 (M[0010] := ACC) 000b1001 (ACC := 0001)pointer = pointer ca011 (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
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
Jon Turner - 5/11/2015 Number Representation n Standard decimal number representation = 2 10 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 A m r m n Binary number representation = 1 2 2 2 n Converting binary numbers to decimal (easy). write binary expansion, replace powers of 2 with decimal values, and add up the values = 1 2 2 2 = 4 = 6.25 Note: it helps to know your powers of 2 ( hint )

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 = ( ) 2 n Works similarly for other number bases.

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. » = = (6542) = (d62) 16 octal conversionhexadecimal conversion 000 = = = = = = = = = 10 = a 011 = = = 11 = b 100 = = = 12 = c 101 = = = 13 = d 110 = = = 14 = e 111 = = = 15 = f

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 ). 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
Jon Turner - 5/11/2015 How Computers Add n Binary long addition similar to decimal long addition. decimal binary carry augend addend sum 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
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” = = = 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
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
Jon Turner - 5/11/2015 Convert Numeric String to Internal Value n ASCII character codes for decimal integer stored in locations with M.S.D. at location 20. Write internal value in location 1f. AddressInstructionComment 0000 (start)1000 (ACC := 0000)result = f (M[001f] := ACC) (ACC := 0020)pointer = d (M[001d] := ACC) 0004 (loop)1025 (ACC := 0025)if pointer = 025, quit (ACC := -ACC) 0006a01d (ACC := ACC + M[001d]) (if 0 goto 0015) a (ACC := 000a)result = 10 * result 0009b01f (ACC := ACC*M[001f]) New multiply inst. 000a401f (M[001f] := ACC)

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]) f (M[001f] := ACC) (ACC := 0001) pointer = pointer a01d (ACC := ACC+M[001d]) d (M[001d] := ACC) (goto 0004)goto loop 0015 (end)0000 (halt)halt dPointer to next char 001eTemporary value 001fStore result here 0020ASCII digits

20
Jon Turner - 5/11/2015 Convert Internal Value to Numeric String Write ASCII character codes for value in location 1f into words 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
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 a ffff... IREGIARACC read/write ALU

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
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

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google