Presentation is loading. Please wait.

Presentation is loading. Please wait.

Comp Sci 251 Intro 1 Computer organization and assembly language Wing Huen.

Similar presentations


Presentation on theme: "Comp Sci 251 Intro 1 Computer organization and assembly language Wing Huen."— Presentation transcript:

1 Comp Sci 251 Intro 1 Computer organization and assembly language Wing Huen

2 Comp Sci 251 Intro 2 Course goals Instruction set architecture – Binary representation of data and instructions – Processor and memory organization

3 Comp Sci 251 Intro 3 Course goals High-level language implementation – Variables – Control structures – Functions/methods

4 Comp Sci 251 Intro 4 Course goals Hardware support of instruction set – Memory hierarchy (cache) – Pipelining

5 Comp Sci 251 Intro 5 Language hierarchy Machine language – Instructions that processor can directly execute – Represented in binary (0’s and 1’s) – Different for each processor (Pentium, MIPS, PowerPC) – What is: 0000001100011010110000000100000? Assembly language – Symbolic names for machine instructions – Example: add $12, $12, $13 High-level languages – Machine-independent – X = y + z;

6 Comp Sci 251 Intro 6 Language translation High-level language Assembly language Machine language compiler assembler

7 Comp Sci 251 Intro 7 Data representation Text and numbers stored in binary (0,1) “Bit”: Binary digit – a single 0 or 1 “Byte”: string of eight bits fundamental unit of computer memory

8 Comp Sci 251 Intro 8 Number Systems Normal humans: use decimal (base ten) Computer scientists: use alternatives – Binary (base two) – Hexadecimal (base sixteen)

9 Comp Sci 251 Intro 9 Number Systems Decimal (base ten; digits 0..9) 857 10 = 8×10 2 + 5×10 1 + 7×10 0 Binary (base two; digits 0..1) 11001 2 = 1×2 4 + 1×2 3 + 0×2 2 + 0×2 1 + 1×2 0

10 Comp Sci 251 Intro 10 Number Systems Hexadecimal (base sixteen; digits 0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f) 4d7a 16 = 4×16 3 + 13×16 2 + 7×16 1 + 10×16 0 Convert the binary number 00000011000110101100000001000000 to Hexadecimal 0x031ac040

11 Comp Sci 251 Intro 11 Decimal  binary conversion Method #1 Write the number as a sum of powers of 2: 2 0, 2 1, 2 2, 2 3, 2 4, 2 5, 2 6, 2 7, 2 8, 2 9, 2 10, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024,... Example: convert 57 10 to binary 57 = 32 + 25 = 32 + 16 + 9 = 32 + 16 + 8 + 1 = 2 5 + 2 4 + 2 3 + 2 0 = 1 1 1 0 0 1 two

12 Comp Sci 251 Intro 12 Decimal  binary conversion Method #2 Repeatedly divide by 2 until the quotient is 0 The remainders are the bits First remainder is least significant bit (lsb) Last remainder is most significant bit (msb) Example: convert 57 10 to binary 57 / 2 = 28 r 1 …

13 Comp Sci 251 Intro 13 Hexadecimal  binary conversion Hexadecimal digit = shorthand for 4 bits 0000 0001 0010 0011 0100 0101 0110 0111 0 1 2 3 4 5 6 7 1000 1001 1010 1011 1100 1101 1110 1111 8 9 a b c d e f Example: convert 6c4d 16 to binary

14 Comp Sci 251 Intro 14 Addition algorithm Works for any base Work from right to left Add carry-in and two digits  one- or two-digit result Sum = least significant digit Carry out = most significant digit Examples: 952 10 + 77 10 2f5 16 111 2 + 1c 16 + 11 2


Download ppt "Comp Sci 251 Intro 1 Computer organization and assembly language Wing Huen."

Similar presentations


Ads by Google