1 / 33

Instruction Sets Week 9

Instruction Sets Week 9. Computer Architecture. Review Keywords & Concepts. English words & ideas you must know: Sign & Magnitude 2 ’ s Complement Booth ’ s Algorithm Exponent Mantissa Significand Biased Overflow Underflow Normalize / renormalize. What we will learn today.

maren
Download Presentation

Instruction Sets Week 9

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Instruction Sets Week 9 Computer Architecture Computer Architecture

  2. Review Keywords & Concepts • English words & ideas you must know: • Sign & Magnitude • 2’s Complement • Booth’s Algorithm • Exponent • Mantissa • Significand • Biased • Overflow • Underflow • Normalize / renormalize Computer Architecture

  3. What we will learn today • Collect Homework • Review last class • Instruction Sets: Characteristics • Machine Instruction Characteristics • Types of Operands • Pentium and PowerPC Data Types • QUIZ Computer Architecture

  4. Computer Arithmetic • Integers • Unsigned • Binary representation 010011 = 0 x 25 + 1 x 24 + 0 x 23 + 0 x 22 + 1 x 21 + 1 x 20 = 1 x 16 + 1 x 2 + 1 x 1 = 19 • Examples: 101 = 5 1000 = 8 1010 = 10 011001 = 25 Computer Architecture

  5. Computer Arithmetic • Integers • Signed • MSB (Most Significant Bit)  sign bit • Bit is 0  positive number • Bit is 1  negative number • Binary representation • Sign & Magnitude • 2’s Complement Computer Architecture

  6. Integers (Sign & Magnitude) • Integers • Signed (Sign & Magnitude representation) • Positive numbers – similar to unsigned binary numbers • Negative numbers • First bit (left most bit  MSB) is sign • 0  positive • 1  negative • Remaining bits • Magnitude (size) of negative number • Example 11100 sign bit is 1  negative number 1100  magnitude  12 so… 11000 is a -12 Computer Architecture

  7. Sign & Magnitude • Advantage • Easy for humans to understand • Disadvantages • Two Zeros (i.e. 1000000 = -0 & 0000000 = +0) • Difficult for computers to understand • It is expensive to make computer hardware to use sign & magnitude Computer Architecture

  8. Integers (2’s compliment) • Integers • Signed (2’s Complement) • Positive numbers – similar to unsigned binary numbers • Negative numbers • First bit (left most bit  MSB) is sign • 0  positive • 1  negative • To determine magnitude of negative number • Flip all the bits (change 0  1 and 1  0) • Add 1 Computer Architecture

  9. 2’s Complement • Advantages • Only 1 zero (i.e. 000000) • Easy for computer to understand • Easy / cheap to build computer hardware / CPU • Disadvantage • Difficult for humans to understand (quickly recognize) REMEMBER: 2’s complement applies to NEGATIVE numbers only! Computer Architecture

  10. Binary Operations • Subtraction • There is NO subtraction in modern computers! • We convert to negative & then add!!! • For example: 9 – 5 [really means (+9) – (+5)] [(+9) + (-5)  actual operation is addition] 9 = 00001001 5 = 00000101 -5 = 11111011 So… 9 – 5 becomes: 00001001 +9 11111011 -5 ------------ --- 00000100 +4 Computer Architecture

  11. Binary Operations • Multiplication (positive numbers) 01101 13 x00011 3 -------- --- 01101 39 01101 --------- 0100111  39 Computer Architecture

  12. Binary Operations • Multiplication (negative numbers) • Use Booth’s Algorithm • Textbook – Page 301 & 302 0111 1001 x1101 (0) x1101 (0) ------------ ------------ 11111001 1-0 00000111 1-0 0000111 0-1 1111001 0-1 111001 1-0 000111 1-0 00000 1-1 00000 1-1 ------------ ------------ 11101011 00010101 (7) X (-3) = -21 (-7) x (-3) = (+21) Computer Architecture

  13. Floating Point Numbers • Binary • SAME idea as Decimal • Format • 1 bit – Sign • 8 bits – Exponent • 23 bits – significand / mantissa Significand or Mantissa Exponent S Computer Architecture

  14. Floating Point Numbers • Addition (Decimal) a = .77 x 102 b = .935 x 103 NOTE: to add or subtract – MUST have same exponent!! a = .077 x 103 b = .935 x 103 a + b = .077 + .935 x 103 = 1.012 x 103 = .1012 x 104 Computer Architecture

  15. Floating Point Numbers • Addition & Subtraction basic rules: • Check for zeros • Align the significands (mantissas) • Add or subtract the significands (mantissas) • Normalize the results Computer Architecture

  16. Floating Point Numbers • Errors • Exponent overflow • Number (exponent) too large • Exponent underflow • Number (exponent) too small • Significand underflow • While aligning significands number becomes zero • Significand overflow • Addition produces a carry which requires a normalization Computer Architecture

  17. Floating Point Numbers • Multiplication (basic rules) • If either number is zero then answer is zero • Add exponents (re-set bias & check for errors – overflow / underflow) • Multiple significands (include sign bit) • Re-normalize Computer Architecture

  18. Special floating point representations • An exponent equal 255 = 11111111(2 in a floating point representation indicates a special value • When the exponent is equal 255 = 11111111(2 and the fraction is 0, the value represented is infinity • When the exponent is equal 255 = 11111111(2 and the fraction is non-zero, the value represented is Not a Number (NaN) Computer Architecture

  19. Machine Instructions • Information required by CPU • Operation Code • Source Operand Reference • Result Operand Reference • Next Instruction reference Computer Architecture

  20. Location of Operand Reference • Main Memory (or cache) a = b + c; (a, b, & c are all memory locations) • Register in CPU c++; (c = c + 1; number 1 may be stored in a register) • I/O Device Computer Architecture

  21. Next Instruction Reference • ‘normally’ the next instruction in memory PC (program counter in CPU is incremented) • Branch or Jump instruction Change PC (i.e. PC = PC + 10) if (x > 0) { a = 10; } else { a = 20; } Computer Architecture

  22. Instruction Representation Assembly Language vs. Machine Language • Assembly language uses mnemonics add r1, y • Machine Language is binary (all 1’s & 0’s) 0110 - Opcode of 4 bits 000001 – Register 1 110111 – Address in memory for y Actual: 011000000110111 Computer Architecture

  23. Instruction Types • Data Processing • Arithmetic Instructions • Logic Instructions • Data Storage • Store data into memory (from CPU) • Fetch data from memory (into CPU) • Data Movement • I/O Instructions • Control • Test Instructions (conditional / if statements) • Branch Instructions (go to or subroutine statements) Computer Architecture

  24. Number of Addresses • Three address instructions sub y,a,b y  a – b Subtract • Two address instructions move y,a y  a Move sub y,b y  y – b Subtract • One address instructions load ac,a ac  a Load sub ac,b ac  ac – b Subtract stor ac,y ac  y Store Computer Architecture

  25. Example • if (x > 0) { a = 10; } else { a = 20;} cmpg x,0 Compare – skip if true jmp z1 Go to z1 loadi ac,20 Load 20 into a register stor ac,a Store 20 into memory a jmp z2 Go to z2 z1: loadi ac,10 Load 10 into a register stor ac,a Store 10 into memory a z2: … Computer Architecture

  26. Types of Operands • Addresses • Locations in main memory • Numbers • Integer (2’s complement) • Floating Point • Decimal (BCD – Binary Coded Decimal) • Characters • ASCII (American Standard Code for Information Interchange) • EBCDIC (Extended Binary Coded Decimal Interchange Code) • Unicode • Logical Data • True (1) / False (0) Computer Architecture

  27. Pentium Data Types • General • Byte (8-bits) • Word (16 bits) • Doubleword (32 bits) • Qualword (64 bits) • Integer (signed - 2’s complement) • Byte, Word, Doubleword • Ordinal (unsigned) • Byte, Word, Doubleword Computer Architecture

  28. Pentium Data Types • Unpacked BCD (Binary Coded Decimal) • Packed BCD (Binary Coded Decimal) • Near Pointer (relative address pointer) • Bit Field (contiguous sequence of bits) • Byte String (contiguous sequence of bytes) • Floating Point (see Figure 10.4 page 340) Computer Architecture

  29. BCD • Binary Coded Decimal • 4-bit code 0 = 0000 5 = 0101 1 = 0001 6 = 0110 2 = 0010 7 = 0111 3 = 0011 8 = 1000 4 = 0100 9 = 1001 • Packed 234  001000110100 • Unpacked 234  00000001 00000011 00000100 Computer Architecture

  30. BCD – Binary Coded Decimal • Advantages • Store large integer numbers – up to 99 digits • Used for business applications (i.e. Cobol) • No rounding errors (<99 digits) • Disadvantages • Takes more memory • Slow to compute • Can be very slow if CPU does not support BCD arithmetic in hardware (must compute in software) Computer Architecture

  31. What you know now • Instructions Sets • Machine Instruction Characteristics • Types of Operands • Pentium and PowerPC Data Types Computer Architecture

  32. Reading • http://en.wikipedia.org/wiki/Instruction_set Next Lecture • Instruction Sets – part 2 Computer Architecture

  33. HomeworkWeek 9 See webpage for homework assignment! Computer Architecture

More Related