Presentation is loading. Please wait.

Presentation is loading. Please wait.

Monday, October 4 Assignment(s) due: Assignment #5: COMPLEMENT ARITHMETIC Assignment #6: DEBUG EXERCISES Quiz(zes) due:Quiz #5: Base Arithmetic Quiz #6.

Similar presentations


Presentation on theme: "Monday, October 4 Assignment(s) due: Assignment #5: COMPLEMENT ARITHMETIC Assignment #6: DEBUG EXERCISES Quiz(zes) due:Quiz #5: Base Arithmetic Quiz #6."— Presentation transcript:

1 Monday, October 4 Assignment(s) due: Assignment #5: COMPLEMENT ARITHMETIC Assignment #6: DEBUG EXERCISES Quiz(zes) due:Quiz #5: Base Arithmetic Quiz #6 (Complement Arithmetic) Note: Quiz #7 (Debug) will be due next Monday Emulator Progress Worksheet 1 will be due next Monday Today is the cutoff date for all Simple Computer labs and assignments And next Monday is the cutoff date for all arithmetic assignments and quizzes (Assignment #5, Quiz #5, Quiz #6, Optional Quizzes #5, #7 and #8) Please note:The date of the midterm is Monday, October 18 - an 8.5 in. * 11 in. cheat sheet will be allowed We will review for the midterm next week I recommend going over the midterm practice exercises before I discuss them on Monday Don't forget the optional quiz: Debug

2 Given the following information in DEBUG: -e 120 34 12 00 01 -u 100, 10A 21F0:0100BB2001MOVBX, 120 21F0:0103BE0200MOVSI, 2 21F0:01060307MOVAX, [BX] 21F0:01080300ADDAX, [BX + SI] Trace through the partial program above, showing the contents of the AX, BX and SI registers AXBXSI

3 Given the following information in DEBUG: -e 120 34 12 00 01 -u 100, 10A 21F0:0100BB2001MOVBX, 120 21F0:0103BE0200MOVSI, 2 21F0:01060307MOVAX, [BX] 21F0:01080300ADDAX, [BX + SI] Trace through the partial program above, showing the contents of the AX, BX and SI registers AXBXSI But first: What does this mean?120 121 122 123

4 Given the following information in DEBUG: -e 120 34 12 00 01 -u 100, 10A 21F0:0100BB2001MOVBX, 120 21F0:0103BE0200MOVSI, 2 21F0:01060307MOVAX, [BX] 21F0:01080300ADDAX, [BX + SI] Trace through the partial program above, showing the contents of the AX, BX and SI registers AXBXSI But first: What does this mean?120 121 122 123 34 12 00 01

5 Given the following information in DEBUG: -e 120 34 12 00 01 -u 100, 10A 21F0:0100BB2001MOVBX, 120 21F0:0103BE0200MOVSI, 2 21F0:01060307MOVAX, [BX] 21F0:01080300ADDAX, [BX + SI] Trace through the partial program above, showing the contents of the AX, BX and SI registers AXBXSI ?0120 ?

6 Given the following information in DEBUG: -e 120 34 12 00 01 -u 100, 10A 21F0:0100BB2001MOVBX, 120 21F0:0103BE0200MOVSI, 2 21F0:01060307MOVAX, [BX] 21F0:01080300ADDAX, [BX + SI] Trace through the partial program above, showing the contents of the AX, BX and SI registers AXBXSI ?0120 ? ?01200002

7 Given the following information in DEBUG: -e 120 34 12 00 01 -u 100, 10A 21F0:0100BB2001MOVBX, 120 21F0:0103BE0200MOVSI, 2 21F0:01060307MOVAX, [BX] 21F0:01080300ADDAX, [BX + SI] Trace through the partial program above, showing the contents of the AX, BX and SI registers AXBXSI ?0120 ? ?01200002 123401200002

8 Given the following information in DEBUG: -e 120 34 12 00 01 -u 100, 10A 21F0:0100BB2001MOVBX, 120 21F0:0103BE0200MOVSI, 2 21F0:01060307MOVAX, [BX] 21F0:01080300ADDAX, [BX + SI] Trace through the partial program above, showing the contents of the AX, BX and SI registers AXBXSI ?0120 ? ?01200002 123401200002 133401200002

9 Review: MOVCX,0003 MOV AX, 0000 ADDAX, CX LOOP106 INT20 Using the LOOP instruction (works with CX): How does the loop instruction work?

10 Review: MOVCX,0003 MOV AX, 0000 ADDAX, CX LOOP106 INT20 Using the LOOP instruction (works with CX): How does the loop instruction work? 1.It decrements CX 2. It checks CX (is CX > 0?) 3.If CX > 0 - it loops to the address specified If CX = 0 - it goes to the next instruction in sequence

11 - each location in the computer is assigned a unique address - memory locations - input/output devices - the address allows them to be recognized by the CPU - the CPU puts the address on the address bus - identified by the decoding circuits - the data bus is used to get data to or from the address - the control bus sends read/write signals - to indicate if the CPU is asking for or sending information - every process in the computer (at every level of the computer) - uses this fetch/decode/execute cycle

12 - each location in the computer is assigned a unique address - memory locations - input/output devices - the address allows them to be recognized by the CPU - the CPU puts the address on the address bus - identified by the decoding circuits - the data bus is used to get data to or from the address - the control bus sends read/write signals - to indicate if the CPU is asking for or sending information CPU (ALU, registers, control unit) RAMROMPrintercd/dvdMonitorKeyboardMouse Address Bus Data Bus Control Bus

13 - the function (or purpose) of the CPU: - to fetch and execute instructions - more efficient if the process is divided - at the same time: - one instruction is being executed, and - the next instruction is being fetched - implemented by theoretically dividing the CPU into: - the execution unit - decodes and executes instructions and - the bus interface unit - fetches the instructions

14 - the execution unit contains - the ALU - performs operations - arithmetic - logical - registers - high speed memory - temporarily store data or addresses - general purpose registers - available to programmers - special purpose registers - e.g. the instruction pointer, the instruction register - not available to programmers - to indicate if the CPU is asking for or sending information - the flags register - is set (or reset) as the result of operations done in the ALU - can be checked by a program - the decoder - determines the type of instruction - interprets it into a form that can be used in the ALU and registers

15 - the bus interface unit - where instructions and data come in from main memory - the bus interface unit delivers them to the execution unit - contains: - the instruction queue - allows the bus interface unit to stay ahead of the execution unit - when the queue is full - the buses are idle - if the program performs a jump - the queue will be changed - the instruction pointer - holds the address of the next instruction to be executed - the address will be placed on the address bus - the segment registers - hold the addresses of the various parts of memory used by the program - where the instructions are stored - where the data is stored - where the program’s stack is located - the execution unit and the bus interface unit work in parallel - but the bus interface unit is always at least one step ahead

16 Registers: General - EAX (accumulator) EAX - 32 bits 8 hexadecimal digits AX - 16 Bits 4 hexadecimal digits AH and AL - 8 bits each 2 hexadecimal digits each - EBX, ECX, EDX - and BX, BH, BL, CX, CH, CL, DX, DH, DL

17 Intel Registers (grouped by function) Data Registers (general purpose) Index Registers (used in string operations) Pointer Registers (used in stack operations) Accumulator register Base register Count register Data register Source Index register Destination Index register Stack Pointer register Base Pointer register EAX EBX ECX EDX ESI ESP EBP EDI

18 Segment Registers (16-bit) (hold segment addresses) Control Registers Flags register detail: - bit 0CF - bit 2PF - bit 6ZF - bit 7SF - bit 10DF - bit 11OF Intel Registers (grouped by function) Code Segment register Data Segment register Stack Segment register Extra Segment register EIP EFLAGS Instruction pointer register Flags register CS DS SS ES

19 - immediate addressing - the operand comes immediately after the instruction e.g. MOV EAX, 12345678 or MOV AX, ABCD or MOV AH, 2A - direct addressing - specifies the address of the operand e.g. MOV EAX, [0100] or MOV EAX, NUMBER - register addressing - specifies the register in which the operand is stored e.g. MOV EAX, EBX 32-bit Addressing Modes

20 Scientific Notation Format Normalized Standard Form Scientific Notation Scientific Notation 3.141593.14159 x 10 0.314159 x 10 1 100,0001.0 x 10 5.1 x 10 6.00011.0 x 10 -4.1 x 10 -3 -1234-1.234 x 10 3 -.1234 x 10 4 -1.234 3 -.1234 4 mantissa characteristic fraction exponent (or significand) Scientific notation makes it relatively easy to work with very large or very small numbers - normalized scientific notation used in the computer is called floating point notation

21 4-Decimal-Digit Floating Point Format Fraction 2 decimal digits Normalized Signed Exponent 2 decimal digits Signed 4 3 3 1 1 1 1 0 00 0 -0 6 0 2 3.14159 100,000.0001 -1234 (.314159 * 10 1 ) (.1 * 10 6 ) (.1 * 10 -3 ) (.1234 * 10 4 )

22 4-Decimal-Digit Floating Point Format Fraction 2 decimal digits Normalized Signed Exponent 2 decimal digits Signed 4 3 3 1 1 1 1 0 00 0 -0 6 0 2 3.14159 100,000.0001 -1234 Range: - defined by the number of digits in the exponent (-.99 x 10 +99.. +.99 x 10 +99 ) Precision: - defined by the number of digits in the fraction (2 digits of precision)

23 - if the 4-decimal digit format is changed: Fraction 3 decimal digits Normalized Signed Exponent 1 decimal digit Signed - the range is smaller (-.999*10 9.. 999*10 9 ) - there is a smaller distance between adjacent numbers - there is greater accuracy

24 - if the 4-decimal digit format is changed: Fraction 1 decimal digit Normalized Signed Exponent 3 decimal digits Signed - the range is increased - accuracy is greatly decreased

25 - if the 4-decimal digit format is changed: Fraction 1 decimal digit Normalized Signed Exponent 3 decimal digits Signed - the range is increased - accuracy is greatly decreased - no matter what format is used - these numbers will generate 7 different regions of storage: - a positive value region, - a negative value region and a - zero region - 2 overflow regions - 2 underflow regions

26 Range and regions of value for a 4-decimal-digit floating point format: Fraction 2 decimal digits Normalized Signed Exponent 2 decimal digits Signed

27 zero.10x10 0.10x10 -99.99x10 99 -.10x10 -99 -.99x10 99 -.10x10 0 Range of 4-decimal-digit floating point format: (using the number line) (Absolutely not to scale) overflow underflow

28 Roundoff Error If we store 3.14159 aswe truncate (round down) to 3.1 If we store 3.14159 aswe round up to 3.2 031 23 1 10 If we store 1234 aswe round down to 1200 4120 Fraction 2 decimal digits Normalized Signed Exponent 2 decimal digits Signed

29 Floating point formats: - often stored in normalized scientific notation form (.xxxxxx * base exponent ) - precision (accuracy) - affected by the number of digits in the fraction - affected by the limits of binary representation - range - determined by the number of digits in the exponent - often generate a round-off error

30 Binary Floating Point Formats - most are based on dividing the binary number into 3 parts: - the sign (1 bit) - 0 = positive, 1 = negative - the exponent - uses excess-N notation - the fractional part - will be normalized - the radix point - will be to the left or right of the most significant bit - depending on the format used A 32-bit floating point number: or

31 To calculate the fraction: - we must know the position of the radix point - to the left or right of the most significant bit

32 To calculate the fraction: - we must know the position of the radix point - to the left or right of the most significant bit(it's to the left)

33 To calculate the fraction: - we must know the position of the radix point - to the left or right of the most significant bit(it's to the left) - and the base that will be used to calculate the exponent - called the radix of exponentiation - usually base 2, 8 or 16

34 To calculate the fraction: - we must know the position of the radix point - to the left or right of the most significant bit(it's to the left) - and the base that will be used to calculate the exponent - called the radix of exponentiation - usually base 2, 8 or 16(we'll look at all three)

35 To calculate the fraction: - we must know the position of the radix point - to the left or right of the most significant bit(it's to the left) - and the base that will be used to calculate the exponent - called the radix of exponentiation - usually base 2, 8 or 16(we'll look at all three) To calculate the exponent: - we must first normalize the fraction to find the exponent - using the radix of exponentiation

36 To calculate the fraction: - we must know the position of the radix point - to the left or right of the most significant bit(it's to the left) - and the base that will be used to calculate the exponent - called the radix of exponentiation - usually base 2, 8 or 16(we'll look at all three) To calculate the exponent: - we must first normalize the fraction to find the exponent - using the radix of exponentiation - if the exponent is stored in 7 bits(it's stored in 7 bits) - it uses excess-64 notation - if the exponent is stored in 8 bits - it uses excess-127 notation

37 The problem: - how 0.001 10 would be represented in a hypothetical machine - using a 32-bit floating point format - 1 bit for the sign bit - (0 = positive, 1 = negative) - 7 bits for the exponent - using excess-64 notation - 24 bits for the fraction - normalized - radix point to the left of the most significant bit - the radix of exponentiation is 2

38 Step 1:Convert 0.001 10 to radix 2 0.001 10 = 0.0004061115645 8 = 0.000000000100000110001001001101110100101 2

39 Step 1:Convert 0.001 10 to radix 2 0.001 10 = 0.0004061115645 8 = 0.000000000100000110001001001101110100101 2 Step 2:Normalize the fraction - move the radix point to the left of the most significant bit - i.e. move the radix point to the right 9 bits = 0.000000000100000110001001001101110100101 2

40 Step 1:Convert 0.001 10 to radix 2 0.001 10 = 0.0004061115645 8 = 0.000000000100000110001001001101110100101 2 Step 2:Normalize the fraction - move the radix point to the left of the most significant bit - move the radix point to the right 9 bits = 0.000000000100000110001001001101110100101 2 - on a computer using radix 2 the normalized form is: = 0.100000110001001001101110 100101 2 * (2 -9 ) 10

41 Step 1:Convert 0.001 10 to radix 2 0.001 10 = 0.0004061115645 8 = 0.000000000100000110001001001101110100101 2 Step 2:Normalize the fraction - move the radix point to the left of the most significant bit - move the radix point to the right 9 bits = 0.000000000100000110001001001101110100101 2 - on a computer using radix 2 the normalized form is: = 0.100000110001001001101110 100101 2 * (2 -9 ) 10 the 24 bits we need for the fraction

42 - normalizing the fraction gives us the fraction in radix 2 and the exponent in radix 10 = 0.100000110001001001101110 100101 2 * (2 -9 ) 10 fraction exponent

43 - normalizing the fraction gives us the fraction in radix 2 and the exponent in radix 10 = 0.100000110001001001101110 100101 2 * (2 -9 ) 10 fraction exponent Step 3: Convert the exponent to its excess-64 form in radix 2 - in radix 10:-9 + 64 = 55 10 - in radix 2:0110111 2

44 - normalizing the fraction gives us the fraction in radix 2 and the exponent in radix 10 = 0.100000110001001001101110 100101 2 * (2 -9 ) 10 fraction exponent Step 3: Convert the exponent to its excess-64 form in radix 2 - in radix 10:-9 + 64 = 55 10 - in radix 2:0110111 2 Step 4:Put the number together sign exponent fraction 0 0110111 100000110001001001101110 or 3 7 8 3 1 2 6 E in hexadecimal

45 The problem: - how 0.001 10 would be represented in a hypothetical machine - using a 32-bit floating point format - 1 bit for the sign bit - (0 = positive, 1 = negative) - 7 bits for the exponent - using excess-64 notation - 24 bits for the fraction - normalized - radix point to the left of the most significant bit - the radix of exponentiation is 8 - for radix 8 we move the radix point in sets of 3 bits (1 octal digit = 3 binary digits)

46 Step 1:Convert 0.001 10 to radix 2 0.001 10 = 0.000000000100000110001001001101110100101 2 Step 2:Normalize the fraction - move the radix point to the left of the most significant bit - move the radix point to the right in sets of 3 bits - and stay to the left of the msb = 0.000000000100000110001001001101110100101 2

47 Step 1:Convert 0.001 10 to radix 2 0.001 10 = 0.000000000100000110001001001101110100101 2 Step 2:Normalize the fraction - move the radix point to the left of the most significant bit - move the radix point to the right in sets of 3 bits - and stay to the left of the msb = 0.000000000100000110001001001101110100101 2 - on a computer using radix 8 the normalized form is: = 0.100000110001001001101110 100101 2 * (8 -3 ) 10 the 24 bits we need for the fraction Note: the roundoff error is truncation error - if the roundoff error was from rounding bit #31 would be a 1

48 - normalizing the fraction gives us the fraction in radix 2 and the exponent in radix 10 = 0.100000110001001001101110 100101 2 * (8 -3 ) 10 fraction exponent Step 3: Convert the exponent to its excess-64 form in radix 2 - in radix 10:-3 + 64 = 61 10 - in radix 2:0111101 2

49 - normalizing the fraction gives us the fraction in radix 2 and the exponent in radix 10 = 0.100000110001001001101110 100101 2 * (8 -3 ) 10 fraction exponent Step 3: Convert the exponent to its excess-64 form in radix 2 - in radix 10:-3 + 64 = 61 10 - in radix 2:0111101 2 Step 4:Put the number together sign exponent fraction 0 0111101 100000110001001001101110 or 3 D 8 3 1 2 6 E in hexadecimal

50 The problem: - how 0.001 10 would be represented in a hypothetical machine - using a 32-bit floating point format - 1 bit for the sign bit - (0 = positive, 1 = negative) - 7 bits for the exponent - using excess-64 notation - 24 bits for the fraction - normalized - radix point to the left of the most significant bit - the radix of exponentiation is 16 - for radix 16 we move the radix point in sets of 4 bits (1 hexadecimal digit = 4 binary digits) (This was the short-form floating point format used on the IBM 370 computer)

51 Step 1:Convert 0.001 10 to radix 2 0.001 10 = 0.000000000100000110001001001101110100101 2 Step 2:Normalize the fraction - move the radix point to the left of the most significant bit - move the radix point to the right in sets of 4 bits - and stay to the left of the msb = 0.000000000100000110001001001101110100101 2

52 Step 1:Convert 0.001 10 to radix 2 0.001 10 = 0.000000000100000110001001001101110100101 2 Step 2:Normalize the fraction - move the radix point to the left of the most significant bit - move the radix point to the right in sets of 4 bits - and stay to the left of the msb = 0.000000000100000110001001001101110100101 2 - on a computer using radix 16 the normalized form is: = 0.010000011000100100110111 0100101 2 * (16 -2 ) 10 the 24 bits we need for the fraction Note: the roundoff error is is the same for rounding or truncation - the next bit is a 0

53 - normalizing the fraction gives us the fraction in radix 2 and the exponent in radix 10 = 0.010000011000100100110111 0100101 2 * (16 -2 ) 10 fraction exponent Step 3: Convert the exponent to its excess-64 form in radix 2 - in radix 10:-2 + 64 = 62 10 - in radix 2:0111110 2

54 - normalizing the fraction gives us the fraction in radix 2 and the exponent in radix 10 = 0.010000011000100100110111 0100101 2 * (16 -2 ) 10 fraction exponent Step 3: Convert the exponent to its excess-64 form in radix 2 - in radix 10:-2 + 64 = 62 10 - in radix 2:0111110 2 Step 4:Put the number together sign exponent fraction 0 0111110 010000011000100100110111 or ? in hexadecimal

55 Conversion to/from floating point formats: - decimal number to hexadecimal floating point format: - convert decimal number to binary - convert to normalized scientific form (varies) - convert exponent to its excess-N form in binary - add sign bit to exponent and fraction - convert binary number to hexadecimal

56 To decode the hexadecimal number 3E400000 (same format):

57 To decode the hexadecimal number 3E400000 (same format): The number in binary:0 011 1110 0100 0000 0000 0000 0000 0000 0 62 10.01 2

58 To decode the hexadecimal number 3E400000 (same format): The number in binary:0 011 1110 0100 0000 0000 0000 0000 0000 0 62 10.01 2 Sign: positive Exponent: -2 10 Fraction:.01 2

59 To decode the hexadecimal number 3E400000 (same format): The number in binary:0 011 1110 0100 0000 0000 0000 0000 0000 0 62 10.01 2 Sign: positive Exponent: -2 10 Fraction:.01 2 The normalized form:.01 x (16 -2 ) 10

60 To decode the hexadecimal number 3E400000 (same format): The number in binary:0 011 1110 0100 0000 0000 0000 0000 0000 0 62 10.01 2 Sign: positive Exponent: -2 10 Fraction:.01 2 The normalized form:.01 x (16 -2) 10 The non-scientific binary form:.0000000001 2

61 To decode the hexadecimal number 3E400000 (same format): The number in binary:0 011 1110 0100 0000 0000 0000 0000 0000 0 62 10.01 2 Sign: positive Exponent: -2 10 Fraction:.01 2 The normalized form:.01 x (16 -2) 10 The non-scientific binary form:.0000000001 2 The number in decimal: = 1/1024 or.0009765... 10

62 Conversion to/from floating point formats: - decimal number to hexadecimal floating point format: - convert decimal number to binary - convert to normalized scientific form (varies) - convert exponent to its excess-N form in binary - add sign bit to exponent and fraction - convert binary number to hexadecimal - hexadecimal floating point format to decimal value - convert hexadecimal number to binary - determine sign, exponent and fraction - convert exponent to its decimal form - convert to normalized form - convert to its non-scientific binary form - convert to decimal

63 The problem from Lab #9: - how -46.74 10 would be represented in a hypothetical machine - using a 32-bit floating point format - 1 bit for the sign bit - (0 = positive, 1 = negative) - 7 bits for the exponent - using excess-64 notation - 24 bits for the fraction - normalized - radix point to the left of the most significant bit - the radix of exponentiation is 16 - for radix 16 we move the radix point in sets of 4 bits (1 hexadecimal digit = 4 binary digits) (This was the short-form floating point format used on the IBM 370 computer)

64 The problem from Lab #9: - how -46.74 10 would be represented in a hypothetical machine - using a 32-bit floating point format - 1 bit for the sign bit - (0 = positive, 1 = negative) - 7 bits for the exponent - using excess-64 notation - 24 bits for the fraction - normalized - radix point to the left of the most significant bit - the radix of exponentiation is 16 - for radix 16 we move the radix point in sets of 4 bits (1 hexadecimal digit = 4 binary digits) (This was the short-form floating point format used on the IBM 370 computer).74 * 2 = 1.48.48 * 2 = 0.96.96 * 2 = 1.92.92 * 2 = 1.84.84 * 2 = 1.68.68 * 2 = 1.36.36 * 2 = 0.72.72 * 2 = 1.44.44 * 2 = 0.88.88 * 2 = 1.76.76 * 2 = 1.52.52 * 2 = 1.04.04 * 2 = 0.08.08 * 2 = 0.16.16 * 2 = 0.32.32 * 2 = 0.64.64 * 2 = 1.28.28 * 2 = 0.56.56 * 2 = 1.12

65 Step 1:Convert -46.74 10 to radix 2 -46.74 10 = -101110.1011110101110000101 2 Step 2:Normalize the fraction - move the radix point to the left of the most significant bit - move the radix point to the left in sets of 4 bits - and stay to the left of the msb = -00101110.1011110101110000101 2 - on a computer using radix 16 the normalized form is: = -.001011101011110101110000 2 * (16 2 ) 10 the 24 bits we need for the fraction Step 3:- the roundoff error is is from rounding - the next bit is a 1 - the normalized form becomes = -.001011101011110101110001 2 * (16 2 ) 10

66 Step 1:Convert -46.74 10 to radix 2 -46.74 10 = -101110.101111010111000010101 2 Step 2:Normalize the fraction - move the radix point to the left of the most significant bit - move the radix point to the left in sets of 4 bits - and stay to the left of the msb = -00101110.101111010111000010 2 - on a computer using radix 16 the normalized form is: = -.001011101011110101110000 2 * (16 2 ) 10 the 24 bits we need for the fraction Step 3:- the roundoff error is is from rounding - the next bit is a 1 - the normalized form becomes = -.001011101011110101110001 2 * (16 2 ) 10

67 Step 1:Convert -46.74 10 to radix 2 -46.74 10 = -101110.10111101011100001010 2 Step 2:Normalize the fraction - move the radix point to the left of the most significant bit - move the radix point to the left in sets of 4 bits - and stay to the left of the msb = -00101110.101111010111000010 2 - on a computer using radix 16 the normalized form is: = -.001011101011110101110000 2 * (16 2 ) 10 the 24 bits we need for the fraction Step 3:- the roundoff error is is from rounding - the next bit is a 1 - the normalized form becomes = -.001011101011110101110001 2 * (16 2 ) 10

68 - normalizing the fraction gives us the fraction in radix 2 and the exponent in radix 10 = -.001011101011110101110001 2 * (16 2 ) 10 fraction exponent Step 3: Convert the exponent to its excess-64 form in radix 2 - in radix 10:2 + 64 = 66 10 - in radix 2:1000010 2 Step 4:Put the number together sign exponent fraction 1 1000010.001011101011110101110001 or C 2 2 E B D 7 1 in hexadecimal

69 - normalizing the fraction gives us the fraction in radix 2 and the exponent in radix 10 = -.001011101011110101110001 2 * (16 2 ) 10 fraction exponent Step 3: Convert the exponent to its excess-64 form in radix 2 - in radix 10:2 + 64 = 66 10 - in radix 2:1000010 2 Step 4:Put the number together sign exponent fraction 1 1000010.001011101011110101110001 or C 2 2 E B D 7 1 in hexadecimal

70 - normalizing the fraction gives us the fraction in radix 2 and the exponent in radix 10 = -.001011101011110101110001 2 * (16 2 ) 10 fraction exponent Step 3: Convert the exponent to its excess-64 form in radix 2 - in radix 10:2 + 64 = 66 10 - in radix 2:1000010 2 Step 4:Put the number together sign exponent fraction 1 1000010.001011101011110101110001 or C 2 2 E B D 7 1 in hexadecimal

71 IEEE Standard Floating Point Formats for the Intel 8087 microprocessor: - the Short Real form:(uses excess-127 for the exponent)

72 IEEE Standard Floating Point Formats for the Intel 8087 microprocessor: - the Short Real form:(uses excess-127 for the exponent) - the Long Real form:(uses excess-1023 for the exponent)

73 The IEEE Short Real form:(and the Long Real form) - divides the binary number into 3 parts: - the sign (1 bit) - 0 = positive, 1 = negative

74 The IEEE Short Real form:(and the Long Real form) - divides the binary number into 3 parts: - the sign (1 bit) - 0 = positive, 1 = negative - the exponent -uses excess-N notation - excess-127 for Short Real - excess-1023 for Long Real -the radix of exponentiation is 2

75 The IEEE Short Real form:(and the Long Real form) - divides the binary number into 3 parts: - the sign (1 bit) - 0 = positive, 1 = negative - the exponent -uses excess-N notation - excess-127 for Short Real - excess-1023 for Long Real -the radix of exponentiation is 2 - the fractional part - normalized using the scientific notation method - with the radix point to the right of the most significant bit (always a 1) - then the msb is implied in the number and not stored - it's considered "hidden" in the floating point format

76 More IEEE Standard Floating Point Formats for the Intel 8087 microprocessor - the Temporary Real form:(uses excess-32767 for the exponent) - the temporary real form: - uses normalized notation - msb to the right of the binary point and NOT hidden - there are also 4 additional formats to handle overflow and underflow

77 The problem: - how 0.001 10 would be represented in a hypothetical machine - using a 32-bit floating point format (IEEE standard) - 1 bit for the sign bit - (0 = positive, 1 = negative) - 8 bits for the exponent - using excess-127 notation - 23 bits for the fraction - normalized - radix point to the right of the most significant bit - msb is "hidden" - the radix of exponentiation is 2

78 Step 1:Convert 0.001 10 to radix 2 0.001 10 = 0.0004061115645 8 = 0.000000000100000110001001001101110100101 2 Step 2:Normalize the fraction - move the radix point to the right of the most significant bit - move the radix point to the right 10 bits = 0.000000000100000110001001001101110100101 2

79 Step 1:Convert 0.001 10 to radix 2 0.001 10 = 0.0004061115645 8 = 0.000000000100000110001001001101110100101 2 Step 2:Normalize the fraction - move the radix point to the right of the most significant bit - move the radix point to the right 10 bits = 0.000000000100000110001001001101110100101 2 - on a computer using radix 2 the normalized form is: = 1.00000110001001001101110 100101 2 * (2 -10 ) 10 the 23 bits we need for the fraction

80 - normalizing the fraction gives us the fraction in radix 2 and the exponent in radix 10 = 1.00000110001001001101110 100101 2 * (2 -10 ) 10 fraction exponent Step 3: Convert the exponent to its excess-127 form in radix 2 - in radix 10:-10 + 127 = 117 10 - in radix 2:01110101 2

81 - normalizing the fraction gives us the fraction in radix 2 and the exponent in radix 10 = 1.00000110001001001101110 100101 2 * (2 -10 ) 10 fraction exponent Step 3: Convert the exponent to its excess-127 form in radix 2 - in radix 10:-10 + 127 = 117 10 - in radix 2:01110101 2 Step 4:Put the number together sign exponent fraction 0 01110101 00000110001001001101110 or 3 A 8 3 1 2 6 E in hexadecimal

82 To decode the hexadecimal number 3D400000 (IEEE format):

83 To decode the hexadecimal number 3D400000 (IEEE format): The number in binary:0 011 1110 0 100 0000 0000 0000 0000 0000 0 124 10.1 2

84 To decode the hexadecimal number 3D400000 (IEEE format): The number in binary:0 011 1110 0 100 0000 0000 0000 0000 0000 0 124 10.1 2 Sign: positive Exponent: -3 Fraction: 1.1

85 To decode the hexadecimal number 3D400000 (IEEE format): The number in binary:0 011 1110 0 100 0000 0000 0000 0000 0000 0 124 10.1 2 Sign: positive Exponent: -3 Fraction: 1.1 The normalized form:1.1 x (2 -3 ) 10

86 To decode the hexadecimal number 3D400000 (IEEE format): The number in binary:0 011 1110 0 100 0000 0000 0000 0000 0000 0 124 10.1 2 Sign: positive Exponent: -3 Fraction: 1.1 The normalized form:1.1 x (2 -3 ) 10 The binary number:.0011 2

87 To decode the hexadecimal number 3D400000 (IEEE format): The number in binary:0 011 1110 0 100 0000 0000 0000 0000 0000 0 124 10.1 2 Sign: positive Exponent: -3 Fraction: 1.1 The normalized form:1.1 x (2 -3 ) 10 The binary number:.0011 2 The decimal number:1/8 +1/16 or 3/16 or.1875 10

88 Conversion to/from floating point formats: - decimal number to hexadecimal floating point format: - convert decimal number to binary - convert to normalized scientific form (varies) - convert exponent to its excess-N form in binary - add sign bit to exponent and fraction - convert binary number to hexadecimal - hexadecimal floating point format to decimal value - convert hexadecimal number to binary - determine sign, exponent and fraction - convert exponent to its decimal form - convert to normalized form - convert to its non-scientific binary form - convert to decimal

89 Monday, October 4 Assignment(s) due: Assignment #5: COMPLEMENT ARITHMETIC Assignment #6: DEBUG EXERCISES Quiz(zes) due:Quiz #5: Base Arithmetic Quiz #6 (Complement Arithmetic) Note: Quiz #7 (Debug) will be due next Monday Emulator Progress Worksheet 1 will be due next Monday Today is the cutoff date for all Simple Computer labs and assignments And next Monday is the cutoff date for all arithmetic assignments and quizzes (Assignment #5, Quiz #5, Quiz #6, Optional Quizzes #5, #7 and #8) Please note:The date of the midterm is Monday, October 18 - an 8.5 in. * 11 in. cheat sheet will be allowed We will review for the midterm next week I recommend going over the midterm practice exercises before I discuss them on Monday Don't forget the optional quiz: Debug

90 The problem from Lab #9 (Part 2): - how -46.74 10 would be represented in a hypothetical machine - using a 32-bit floating point format - 1 bit for the sign bit - (0 = positive, 1 = negative) - 8 bits for the exponent - using excess-127 notation - 24 bits for the fraction - normalized - radix point to the right of the most significant bit - and the most significant bit is "hidden" - the radix of exponentiation is 2 - for radix 2 we move the radix point bit by single bit (This is the IEEE standard short-form floating point format).74 * 2 = 1.48.48 * 2 = 0.96.96 * 2 = 1.92.92 * 2 = 1.84.84 * 2 = 1.68.68 * 2 = 1.36.36 * 2 = 0.72.72 * 2 = 1.44.44 * 2 = 0.88.88 * 2 = 1.76.76 * 2 = 1.52.52 * 2 = 1.04.04 * 2 = 0.08.08 * 2 = 0.16.16 * 2 = 0.32.32 * 2 = 0.64.64 * 2 = 1.28.28 * 2 = 0.56.56 * 2 = 1.12

91 Step 1:Convert -46.74 10 to radix 2 -46.74 10 = -101110.1011110101110000101 2 Step 2:Normalize the fraction - move the radix point to the right of the most significant bit - move the radix point to the left bit by bit = -00101110.1011110101110000101 2 - on a computer using radix 16 the normalized form is: = -1.01110101111010111000010 2 * (2 5 ) 10 the 23 bits we need for the fraction Step 3:- the roundoff error is is from rounding - the next bit is a 1 - the normalized form becomes = -1.01110101111010111000011 2 * (2 5 ) 10

92 Step 1:Convert -46.74 10 to radix 2 -46.74 10 = -101110.1011110101110000101 2 Step 2:Normalize the fraction - move the radix point to the right of the most significant bit - move the radix point to the left bit by bit = -00101110.1011110101110000101 2 - on a computer using radix 16 the normalized form is: = -1.01110101111010111000010 2 * (2 5 ) 10 the 23 bits we need for the fraction Step 3:- the roundoff error is is from rounding - the next bit is a 1 - the normalized form becomes = -1.01110101111010111000011 2 * (2 5 ) 10

93 Step 1:Convert -46.74 10 to radix 2 -46.74 10 = -101110.1011110101110000101 2 Step 2:Normalize the fraction - move the radix point to the right of the most significant bit - move the radix point to the left bit by bit = -00101110.1011110101110000101 2 - on a computer using radix 16 the normalized form is: = -1.01110101111010111000010 2 * (2 5 ) 10 the 23 bits we need for the fraction Step 3:- the roundoff error is is from rounding - the next bit is a 1 - the normalized form becomes = -1.01110101111010111000011 2 * (2 5 ) 10

94 - normalizing the fraction gives us the fraction in radix 2 and the exponent in radix 10 = -1.01110101111010111000011 2 * (2 5 ) 10 fraction exponent Step 3: Convert the exponent to its excess-127 form in radix 2 - in radix 10:5 + 127 = 132 10 - in radix 2:10000100 2 Step 4:Put the number together sign exponent fraction 1 10000100.01110101111010111000011 or C 2 3 A F 5 C 3 in hexadecimal

95 Step 4:Put the number together sign exponent fraction 1 10000100.01110101111010111000011 or C 2 3 A F 5 C 3 in hexadecimal - normalizing the fraction gives us the fraction in radix 2 and the exponent in radix 10 = -1.01110101111010111000011 2 * (2 5 ) 10 fraction exponent Step 3: Convert the exponent to its excess-127 form in radix 2 - in radix 10:5 + 127 = 132 10 - in radix 2:10000100 2

96 - normalizing the fraction gives us the fraction in radix 2 and the exponent in radix 10 = -1.01011101011110101110001 2 * (2 5 ) 10 fraction exponent Step 3: Convert the exponent to its excess-64 form in radix 2 - in radix 10:5 + 127 = 132 10 - in radix 2:10000100 2 Step 4:Put the number together sign exponent fraction 1 10000100.01110101111010111000011 or C 2 3 A F 5 C 3 in hexadecimal


Download ppt "Monday, October 4 Assignment(s) due: Assignment #5: COMPLEMENT ARITHMETIC Assignment #6: DEBUG EXERCISES Quiz(zes) due:Quiz #5: Base Arithmetic Quiz #6."

Similar presentations


Ads by Google