------------------------- Week 08 Notes for CST8214 ------------------------- -Ian! D. Allen - idallen@idallen.ca - www.idallen.com Remember - knowing how to find out an answer is more important than memorizing the answer. Learn to fish! RTFM! (Read The Fine Manual) In Week 10 is your second midterm test: 13h00 Tuesday March 18. Lab answers will be posted shortly after the due date. Not all questions will be marked. Check all your answers against the posted answer set. See the updated Course Notes file: text_errata.txt Class Notes http://teaching.idallen.com/cst8214/08w/ bit_operations.txt Bitwise Operations, bit masking - AND, OR, NOT test2topics.txt Test 2 (Tuesday) Review Topics and Questions text_errata.txt Errors in The Essentials of Computer Organization and Architecture Review ------ The range of IEEE754 single-precision floating-point is approximately: -2**127 to +2**127 -or- -10**38 to +10**38 (approximately) see http://steve.hollasch.net/cgindex/coding/ieeefloat.html Floating-point underflow happens for IEEE754 single-precision floating-point values closer to zero than 2**(-127) which is approximately 10**(-38) [actually about 5.9 x 10**(-39), but 10**(-38) is easier to remember] How can you tell if bit pattern 0x5A5A is ASCII or a number? (you can't) Read and review the Class Notes file bit_operations.txt - bitwise AND, bitwise OR, biwise NOT - word length affects bitwise NOT (why?) - undersand C language expressions, e.g. char x = ~0x7; To calculate number of address lines needed to address memory: - use the exponent from the power of two, e.g. 2**24 cells need 24 lines - the MAR holds the memory address; the MBR holds the data value MARIE ----- Instruction Set Architecture: different for each brand of CPU - MARIE only has room for 4-bits, 2**4 opcodes, real chips have hundreds - we start with nine opcodes 1-9 and explain the others later - slides 26-29 Register Transfer Notation/Language (RTN or RTL) - slides 30-32 - gives the data path of data in the computer (Slide 23), e.g. LOAD X has this RTN: 1) MAR <-- X 2) MBR <-- M[MAR] 3) AC <-- MBR SKIPCOND has this complex RTN: if COND = 00 then if AC < 0 then PC <-- PC + 1 else if COND = 01 then if AC == 0 then PC <-- PC + 1 else if COND = 11 then if AC > 0 then PC <-- PC + 1 The Instruction Cycle (revised) ------------------------------- - don't think "fetch/decode/execute", think "fetch/increment/execute" - see file text_errata.txt in the Class Notes - the book is wrong in section 4.9.1 #4 and Figure 4.11 (not all memory access *reads* the memory!) - a full RTN cycle for LOAD X becomes: FETCH: MAR <-- PC IR <-- M[MAR] INCREMENT: PC <-- PC + 1 EXECUTE: (LOAD) MAR <-- X MBR <-- M[MAR] AC <-- MBR - a full cycle for JUMP X becomes: FETCH: MAR <-- PC IR <-- M[MAR] INCREMENT: PC <-- PC + 1 EXECUTE: (JUMP) PC <-- X - note the "useless" increment of the PC before the jump: the X value address immediately over-writes the incremented PC Omit the sections on interrupts (sections 4.7 and 4.9.2). The Big Picture - Part II ------------------------- See also the Course Notes file named: week04notes.txt Bit patterns have no inherent meaning. They may represent signed integers, unsigned integers, floating point numbers, characters, or even executable program instructions. The instructions that operate on the bits give the bits meaning. You write the programs that generate those instructions. Example: The 32-bit pattern 00111111100000000000000000000000 (3F800000h) If you interpret this 32-bit pattern as: 1. unsigned integer -> 1065353216 decimal 2. sign/magnitude -> 1065353216 decimal 3. two's complement -> 1065353216 decimal 4. IEEE 754 SP FP -> 1.0 decimal 5. Four 7-bit ASCII characters (in 8-bit bytes): 00111111 = 63 decimal = '?' (question mark character) 10000000 = 128 decimal = NOT ASCII (ASCII is only 0-127 decimal) 00000000 = 0 = NUL (control character - not printable) 00000000 = 0 = NUL (control character - not printable) 6. Two 16-bit MARIE instructions (Table 4.2 and 4.6 p.193,209): 0011 111110000000 = ADD 3968 0000 000000000000 = JNS 0 Example: The 32-bit pattern 10111111100000000000000000000000 (BF800000h) If you interpret this 32-bit pattern as: 1. unsigned integer -> 3212836864 decimal 2. sign/magnitude -> -1065353216 decimal 3. two's complement -> -1082130431 decimal 4. IEEE 754 SP FP -> -1.0 decimal 5. Four 7-bit ASCII characters (in 8-bit bytes): 10111111 = 191 decimal = NOT ASCII (ASCII is only 0-127 decimal) 10000000 = 128 decimal = NOT ASCII (ASCII is only 0-127 decimal) 00000000 = 0 = NUL (control character - not printable) 00000000 = 0 = NUL (control character - not printable) 6. Two 16-bit MARIE instructions (Table 4.2 and 4.6 p.193,209): 1011 111110000000 = ADDI 3968 0000 000000000000 = JNS 0 Numbers represented in computers have a limited size (number of bits), hence limited precision and limited range. Numbers can be stored as integers or as floating-point values. Both precision and range are essentially the same for integers, since integers have no exponent field. Floating point numbers have both a mantissa (for precision) and an exponent field (for range); they usually trade away some precision in favour of greater range. Though floating-point numbers almost always have a greater range than integers, the range is not infinite. To store a value accurately in a floating-point representation in a computer, two things must work out: the number's value must lie within the *range* of the floating-point representation (the exponent must fit), and the value must not lose any *precision* (the mantissa must fit). In practice, some precision is often lost when working with floating-point numbers. Bit patterns have no inherent meaning. Your computer programs choose the meaning.