SlideShare ist ein Scribd-Unternehmen logo
1 von 46
Downloaden Sie, um offline zu lesen
1
1
Today: Floating Arithmetic
(H&H 5.3)
Next: Assembly Language Basics
(H&H 6.1-6.2)
Lecture Topics
2
Self-study Module #5 (this week)
Project #5 (due no later than 10/3)
Project #6 (due no later than 10/17)
Exam #1 – Thursday, 10/10
Announcements
2
3
Thursday, 10/10 during lecture
18% of course grade
Bring #2 pencils (multiple choice)
Bring MSU ID
One 8.5x11 note sheet allowed
Old exam on course website
Exam #1
4
Single precision: 32 bits (4 bytes)
Double precision: 64 bits (8 bytes)
IEEE-754 Floating Point Formats
3
5
value double precision single precision
----- ---------------- ----------------
+inf 7FF0000000000000 7F800000
+99.5 4058E00000000000 42C70000
+15.0 402E000000000000 41700000
+10.75 4025800000000000 412C0000
+10.5 4025000000000000 41280000
+10.0 4024000000000000 41200000
+3.3 400A666666666666 40533333
+3.25 400A000000000000 40500000
+3.0 4008000000000000 40400000
+2.1 4000CCCCCCCCCCCD 40066666
+1.5 3FF8000000000000 3FC00000
+1.25 3FF4000000000000 3FA00000
+1.0 3FF0000000000000 3F800000
+0.5 3FE0000000000000 3F000000
+0.25 3FD0000000000000 3E800000
+0.0 0000000000000000 00000000
-0.0 8000000000000000 80000000
6
Format:
sign of fraction 1 bit
biased exponent 11 bits
fraction 52 bits
Interpretation:
+/- 1.fraction x 2(biased exponent – 0x3FF)
Double Precision
4
7
Range of DP exponents:
111 1111 1111 Special (Infinity, NaNs)
111 1111 1110 Largest (+0x3FF or +1023)
...
100 0000 0001 +2
100 0000 0000 +1
011 1111 1111 +0
011 1111 1110 -1
011 1111 1101 -2
...
000 0000 0001 Smallest (-0x3FE or -1022)
000 0000 0000 Special (Zero, Denormals)
8
Format:
sign of fraction 1 bit
biased exponent 8 bits
fraction 23 bits
Interpretation:
+/- 1.fraction x 2(biased exponent – 0x7F)
Single Precision
5
9
Range of SP exponents:
1111 1111 Special (Infinity, NaNs)
1111 1110 Largest (+0x7F or +127)
...
1000 0001 +2
1000 0000 +1
0111 1111 +0
0111 1110 -1
0111 1101 -2
...
0000 0001 Smallest (-0x7E or -126)
0000 0000 Special (Zero, Denormals)
10
Four categories of special values:
Infinity
Not-A-Number
Zero
Denormal Values
All other values called “normalized”
Special Values
6
11
Biased exponent field all ones
Infinity – fraction field all zeroes
7FF0000000000000
NaN – fraction field not all zeroes
7FF0000000000001
Sign bit can be 1 (for negative); set of 253
different representations of NaN
12
Biased exponent field all zeroes
Zero – fraction field all zeroes
0000000000000000
Denormal – fraction field not all zeroes
0000000000000001
Sign bit can be 1 (for negative); set of 253
different denormal values
7
13
Denormal values are smaller than the
minimal normalized value – they allow us to
have values which are close to zero.
Normalized: 1.fraction x 2(Biased-0x3FF)
Denormal: 0.fraction x 2-0x3FE
All double precision denormal values have
the same true exponent (-0x3FE or -1022)
Denormal (Subnormal) Values
14
Assume only 6 bits available (artificial).
Format:
sign of fraction 1 bit
biased exponent 2 bits
fraction 3 bits
Interpretation:
+/- 1.fraction x 2
(biased exponent – 0x1)
6-bit Precision
8
15
Range of exponents:
11 Special (Infinity, NaNs)
10 Largest (+0x1 or +1)
01 Smallest (+0x0 or +0)
00 Special (Zero, Denormals)
Set of positive and negative values
symmetric (just like SP and DP formats)
Clearly artificial, but able to enumerate all
possibilities
16
Infinity and NaNs (8 bit patterns)
encoding binary value decimal value
-------- ------------------- -------------
011111 NaN
011110 NaN
011101 NaN
011100 NaN
011011 NaN
011010 NaN
011001 NaN
011000 Infinity
9
17
True Exponent of 1 (8 bit patterns)
encoding binary value decimal value
-------- ------------------- -------------
010111 1.111e+1 (11.11) 3.75
010110 1.110e+1 (11.10) 3.50
010101 1.101e+1 (11.01) 3.25
010100 1.100e+1 (11.00) 3.00
010011 1.011e+1 (10.11) 2.75
010010 1.010e+1 (10.10) 2.50
010001 1.001e+1 (10.01) 2.25
010000 1.000e+1 (10.00) 2.00
18
True Exponent of 0 (8 bit patterns)
encoding binary value decimal value
-------- ------------------- -------------
001111 1.111e+0 (1.111) 1.875
001110 1.110e+0 (1.110) 1.750
001101 1.101e+0 (1.101) 1.625
001100 1.100e+0 (1.100) 1.500
001011 1.011e+0 (1.011) 1.375
001010 1.010e+0 (1.010) 1.250
001001 1.001e+0 (1.001) 1.125
001000 1.000e+0 (1.000) 1.000
10
19
Zero and Denormals (8 bit patterns)
encoding binary value decimal value
-------- ------------------- -------------
000111 0.111e+0 (0.111) 0.875
000110 0.110e+0 (0.110) 0.750
000101 0.101e+0 (0.101) 0.625
000100 0.100e+0 (0.100) 0.500
000011 0.011e+0 (0.011) 0.375
000010 0.010e+0 (0.010) 0.250
000001 0.001e+0 (0.001) 0.125
000000 Zero
20
encoding binary value decimal value
-------- ------------------- -------------
011111 NaN
..
011000 Infinity
010111 1.111e+1 (11.11) 3.75
.. (0.25)
010000 1.000e+1 (10.00) 2.00
001111 1.111e+0 (1.111) 1.875
.. (0.125)
001000 1.000e+0 (1.000) 1.000
000111 0.111e+0 (0.111) 0.875
.. (0.125)
000000 Zero
11
21
Floating Point Representation:
N bits ==> 2N
values
Sign and magnitude system: half of values
negative
Infinity and NaNs: biased exponent field
all 1’s
Zero and Denormals: biased exponent field
all 0’s
22
Floating Point Representation:
Only sums of powers of 2 are representable
ex: 25
+ 23
+ 2-1
+ 2-3
+ 2-7
+ 2-12
Gap between adjacent values increases as
you move away from Zero
12
23
Approximate ranges:
single double
max normal 3.4 x 10
38
1.8 x 10
308
min normal 1.2 x 10
-38
2.3 x 10
-308
min subnormal 1.4 x 10
-45
4.9 x 10
-324
Approximate significant digits:
single 7
double 16
24
Problems with floating point values:
Overflow – exponent too large to represent
(map value to Infinity)
Underflow – exponent too small to represent
(map value to Zero)
Loss of precision – value requires too many
bits to represent (truncate and round)
13
25
Represent 4.0 in 6-bit format:
4.0 base 10 = 100.0 base 2
normalize: 1.000 x 2
2
base 2
exponent = 2, too large
result: Infinity
26
Represent 0.0625 in 6-bit format:
0.0625 base 10 = 0.0001 base 2
normalize: 1.000 x 2-4
base 2
exponent = -4, too small
result: Zero
14
27
Represent 2.3125 in 6-bit format:
2.3125 base 10 = 10.0101 base 2
normalize: 1.00101 x 2
1
round: 1.001
+0.000 (since next bit is 0)
1.001
exponent = 1, OK
result: 2.25 base 10
28
Represent 3.875 in 6-bit format:
3.875 base 10 = 11.111 base 2
normalize: 1.1111 x 21
base 2
round: 1.111
+0.001 (since next bit is 1)
10.000
normalize: 1.000 (add 1 to exp)
exponent = 2, too large (Infinity)
15
29
Typical operations:
Addition
Subtraction
Multiplication
Division
Square root
Floating Point Operations
30
Floating Point Addition / Subtraction
Assume base 10, all values have 2 digits:
1.5 x 103
1.5 x 103
+ 8.7 x 101
==> + 0.087 x 103
? 1.587 x 10
3
normalize: 1.587 x 103
round: 1.6 x 103
16
31
Assume base 10, all values have 2 digits:
8.6 x 10
3
0.86 x 10
4
+ 9.4 x 10
4
==> + 9.4 x 10
4
? 10.26 x 10
4
normalize: 1.026 x 10
5
round: 1.0 x 105
32
Assume base 10, all values have 2 digits:
5.7 x 103
0.57 x 104
+ 9.4 x 10
4
==> + 9.4 x 10
4
? 9.97 x 10
4
normalize: 9.97 x 10
4
round: 10.0 x 10
4
normalize: 1.00 x 10
5
round: 1.0 x 105
17
33
Assume base 10, all values have 2 digits:
8.2 x 10
4
8.2 x 10
4
+ 7.5 x 10
1
==> + 0.0075 x 10
4
? 8.2075 x 10
4
normalize: 8.2075 x 10
4
round: 8.2 x 10
4
34
Assume base 10, all values have 2 digits:
6.5 x 107
6.5 x 107
- 8.2 x 10
6
==> - 0.82 x 10
7
? 5.68 x 10
7
normalize: 5.68 x 10
7
round: 5.7 x 10
7
18
35
Assume base 10, all values have 2 digits:
7.3 x 10
6
7.3 x 10
6
- 7.2 x 10
6
==> - 7.2 x 10
6
? 0.1 x 10
6
normalize: 1.0 x 10
5
round: 1.0 x 10
5
36
Patterson and Hennessy
Floating point addition:
Normalization may cause
overflow or underflow.
Rounding may produce an
unnormalized result (must
repeat the step to normalize).
19
37
Example:
1. Unpack fields
2. Insert leading ones
3. Compare exponents
4. Shift smaller exponent
5. Add mantissas
6. Normalize mantissa,
adjust exponent
7. Round result
8. Pack fields
38
Circuit for
addition
20
39
Floating Point Multiplication
Assume base 10, all values have 2 digits:
2.5 x 10
3
* 1.3 x 104
3.25 x 10
7
normalize: 3.25 x 107
round: 3.3 x 107
40
Floating Point Multiplication
Assume base 10, all values have 2 digits:
3.2 x 105
* 1.1 x 103
3.52 x 10
8
normalize: 3.52 x 108
round: 3.5 x 108
21
41
Floating Point Multiplication
Assume base 10, all values have 2 digits:
3.5 x 10
5
* 4.0 x 105
14.00 x 10
10
normalize: 1.400 x 1011
round: 1.4 x 1011
42
Patterson and Hennessy
Floating point multiplication:
Normalization may cause
overflow or underflow.
Rounding may produce an
unnormalized result (must
repeat the step to normalize).
1
1
Today: Assembly Language Basics
(H&H 6.1-6.2)
Next: continued
Lecture Topics
2
Project #6 (due no later than 10/17)
Exam #1 – Thursday, 10/10
Announcements
2
3
Thursday, 10/10 during lecture
18% of course grade
Bring #2 pencils (multiple choice)
Bring MSU ID
One 8.5x11 note sheet allowed
Old exam on course website
Exam #1
4
Major themes:
• programming in C (using "gcc")
• integer bitwise and shift operations
• floating point arithmetic
Library module (function “mult")
Driver module (function "main")
Project #6
3
5
// Union: same area of memory, two types
union sp_item
{
float frep;
unsigned irep;
};
// Declare object of type "union sp_item"
union sp_item num;
// Work with type "float"
num.frep = 24.5;
// Work with both types
printf( "%f %08x n", num.frep, num.irep );
6
Communication among components is handled by a
shared pathway called the system bus, which is made up
of the data bus, the address bus, and the control bus.
There is also a power bus, and some architectures may
also have a separate I/O bus.
Review: The System Bus Model
4
7
I/O module: handles all input and output (human
oriented and secondary storage)
Memory module: 2
32
bytes of RAM
CPU module:
Control Unit
Integer Unit
Floating Point Unit
Coprocessor (optional)
ARM Model
8
RAMControl
Unit
Integer
Unit
FP
Unit
CP
ARM Microprocessor
RAM: holds program -- machine instructions and data
Control Unit: manages all other units
Integer Unit: circuits for integer operations
Floating Point Unit: circuits for floating point operations
Coprocessor: specialized circuits (optional)
5
9
Manages the fetch-execute cycle, controls
the other modules.
Control Unit Registers (32 bits):
PC – address of current instruction
IR – bit pattern of current instruction
ARM Control Unit
10
Fetch Phase:
RAM[ PC ] IR
Execute Phase:
decode IR
take appropriate action
update PC (usually PC + 4 PC)
ARM Fetch-Execute Cycle
6
11
Tightly coupled with Control Unit.
Handles all integer calculations.
Integer Unit Registers (32 bits):
General purpose registers (r0 – r15)
CPSR (current program status register):
includes NZCV status bits
ARM Integer Unit
12
Contents of the general-purpose registers (r0-r15), as well
as CPSR at some instant:
IU REGISTERS cpsr: 40000010 icc: 4 (-Z--)
r00: 00000000 r04: 000219d4 r08: 0000000f r12: 000219d4
r01: ffffffff r05: 000219e8 r09: 00000017 r13: 000219d8
r02: 00000000 r06: 00000000 r10: 00000012 r14: 000219dc
r03: 00000000 r07: 00000000 r11: 0000001d r15: 000103e8
ARM Integer Unit
7
13
ARM Data Manipulation
Register
File
ALU
RS1
RS2
RD
4
4
4
32
32
32
14
Let's look at a very simple C program and
discuss the steps required to translate the
program from C into ARM machine
language, then load and execute that
machine language program.
Translation and Execution
8
15
<1 lemon: > cat simple.c
int A = 12;
int B = 27;
int C = -1;
int main()
{
C = A + B;
return 0;
}
16
The text file “simple.c” resides on disk. Run “gcc”
to translate and link that program, creating the
executable file “a.out” (which also resides on disk):
<2 lemon: > gcc -Wall simple.c
Load “a.out” to execute the program: have the
operating system copy the contents of “a.out” into
RAM, set the program counter to the first machine
language instruction in the program, then let the
fetch-execute cycle take over:
<3 lemon: > a.out
9
17
The machine language
instructions from “a.out”
after the file is loaded
into memory.
Addresses are 32 bits:
0001040c
Machine language
instructions are 32 bits:
e1a00003
000103e8: e52db004
000103ec: e28db000
000103f0: e59f3024
000103f4: e5932000
000103f8: e59f3020
000103fc: e5933000
00010400: e0823003
00010404: e59f2018
00010408: e5823000
0001040c: e1a00003
00010410: e24bd000
00010414: e49db004
00010418: e12fff1e
0001041c: 000205c0
00010420: 000205c4
00010424: 000205c8
18
The variables (and
initial values) from
“a.out” after the file is
loaded into memory.
Addresses are 32 bits:
000205c0
Variables of type “int”
are 32 bits:
0000000c
000205c0: 0000000c
000205c4: 0000001b
000205c8: ffffffff
10
19
Outline for function "main":
Get address of A
Load value of A
Get address of B
Load value of B
Add value of A, value of B
Get address of C
Store result at C
20
000103e8: e52db004
000103ec: e28db000
000103f0: e59f3024
000103f4: e5932000
000103f8: e59f3020
000103fc: e5933000
00010400: e0823003
00010404: e59f2018
00010408: e5823000
0001040c: e1a00003
00010410: e24bd000
00010414: e49db004
00010418: e12fff1e
0001041c: 000205c0
00010420: 000205c4
00010424: 000205c8
.
.
000205c0: 0000000c
000205c4: 0000001b
000205c8: ffffffff
Two segments:
0001xxxx: instructions
0002xxxx: data
11
21
000103e8: e52db004 push {fp}
000103ec: e28db000 add fp, sp, #0
000103f0: e59f3024 ldr r3, [pc, #36]
000103f4: e5932000 ldr r2, [r3]
000103f8: e59f3020 ldr r3, [pc, #32]
000103fc: e5933000 ldr r3, [r3]
00010400: e0823003 add r3, r2, r3
00010404: e59f2018 ldr r2, [pc, #24]
00010408: e5823000 str r3, [r2]
0001040c: e1a00003 mov r0, r3
00010410: e24bd000 sub sp, fp, #0
00010414: e49db004 pop {fp}
00010418: e12fff1e bx lr
0001041c: 000205c0 .word 0x000205c0
00010420: 000205c4 .word 0x000205c4
00010424: 000205c8 .word 0x000205c8
22
Each machine language instruction is 32 bits
Fields within each machine language
instruction identify:
• specific operation
• options
• source operands
• destination register
ARM Machine Language
12
23
Express instructions in symbolic form, have
software translate them into machine language
instructions
Instructions: text file
Software: assembler
Assembler reads text file (".s" file), outputs to
binary file (".o" file)
ARM Assembly Language
24
CSE Pi array: 22 ARM V7 systems
ARM V7 characteristics
• RISC design
• Load-store architecture
• addresses: 32 bits
• address space: 2^32 = 4 GB
• register file: 16 32-bit registers (r0-r15)
• machine language instructions: 32 bits
Summary: ARM microprocessor
13
25
Tightly coupled with Control Unit.
Handles all integer calculations.
Integer Unit Registers (32 bits):
General purpose registers (r0 – r15)
CPSR (current program status register):
includes NZCV status bits
ARM Integer Unit
26
ARM Data Manipulation
Register
File
ALU
RS1
RS2
RD
4
4
4
32
32
32
14
27
Data processing instructions (16):
• bitwise (logical) instructions (4)
• arithmetic (add/sub) instructions (6)
• move instructions (2)
• comparison (test) instructions (4)
ARM Data Manipulation
28
Four instructions:
• AND
• ORR (inclusive or)
• EOR (exclusive or)
• BIC (bit clear)
Three registers:
result <== operand1 op operand2
Bitwise (logical) instructions
15
29
r0 <== r6 AND r7
and r0, r6, r7
e0060007
r1 <== r6 OR r7
orr r1, r6, r7
e1861007
Examples
30
r2 <== r6 XOR r7
eor r2, r6, r7
e0262007
r3 <== r6 AND NOT r7
bic r3, r6, r7
e1c63007
Examples
16
31
r0 r7r6AND
assembly: and r0, r6, r7
machine language: e0060007
machine language in binary:
11100000000001100000000000000111
Decoding machine language
32
r1 r7r6ORR
assembly: orr r1, r6, r7
machine language: e1861007
machine language in binary:
11100001100001100001000000000111
Decoding machine language
17
33
r2 r7r6EOR
assembly: eor r2, r6, r7
machine language: e0262007
machine language in binary:
11100000001001100010000000000111
Decoding machine language
34
r3 r7r6BIC
assembly: bic r3, r6, r7
machine language: e1c63007
machine language in binary:
11100001110001100011000000000111
Decoding machine language
18
35
Six instructions:
• ADD
• ADC (add with carry flag)
• SUB
• SBC (subtract with carry flag)
• RSB (reverse subtract)
• RSC (reverse subtract with carry flag)
Three registers: result <== op1 op op2
Arithmetic (add/sub) instructions
36
r0 <== r6 + r7
add r0, r6, r7
e0860007
r1 <== r6 + r7 + carry flag
adc r1, r6, r7
e0a61007
Examples
19
37
r2 <== r6 - r7
sub r2, r6, r7
e0462007
r3 <== r6 - r7 - NOT carry flag
sbc r3, r6, r7
e0c63007
Examples
38
r4 <== r7 - r6
rsb r4, r6, r7
e0664007
r5 <== r7 - r6 - NOT carry flag
rsc r5, r6, r7
e0e65007
Examples
20
39
r0 r7r6ADD
assembly: add r0, r6, r7
machine language: e0860007
machine language in binary:
11100000100001100000000000000111
Decoding machine language
40
r2 r7r6SUB
assembly: sub r2, r6, r7
machine language: e0462007
machine language in binary:
11100000010001100010000000000111
Decoding machine language
21
41
Two instructions:
• MOV
• MVN (move not)
Two registers:
result <== operand2
(operand1 is missing)
Move instructions
42
r0 <== r7
mov r0, r7
e1a00007
r1 <== NOT r7
mvn r1, r7
e1e01007
Examples
22
43
r0 r7not
used
MOV
assembly: mov r0, r7
machine language: e1a00007
machine language in binary:
11100001101000000000000000000111
Decoding machine language
44
r1 r7not
used
MVN
assembly: mvn r1, r7
machine language: e1e01007
machine language in binary:
11100001111000000001000000000111
Decoding machine language
23
45
Each ARM machine language instruction
is 32 bits wide (4 bytes)
• Operation code: bits 24:21
• Destination register: bits 15:12
• Source register #1: bits 19:16
• Source register #2: bits 3:0
What are the other bits used for?
Summary (so far)
46
Format:
Data processing instructions
24
47
S bit: when the S bit is 1, NZCV condition
code flags are updated by the instruction
I bit: when I bit is 1, the second operand is
an 8-bit immediate value (rather than a
register)
cond: will always be 1110 (for now)
Data processing instructions
48
r10 <== r6 + r7
add r10, r6, r7
e086a007
r10 <== r6 + r7, update NZCV flags
adds r10, r6, r7
e096a007
Example: S bit
25
49
r0 <== r6 + 1
add r0, r6, #1
e2860001
r0 <== r6 + 0xff
add r0, r6, #0xff
e28600ff
Example: I bit
50
r0 0xffr6ADD
I bit S bit
assembly: add r0, r6, #0xff
machine language: e28600ff
machine language in binary:
11100010100001100000000011111111
Decoding machine language

Weitere ähnliche Inhalte

Was ist angesagt?

Number system
Number systemNumber system
Number systemaviban
 
Computer arthtmetic,,,
Computer arthtmetic,,,Computer arthtmetic,,,
Computer arthtmetic,,,Ahsan Mehmood
 
Data types - things you have to know!
Data types - things you have to know!Data types - things you have to know!
Data types - things you have to know!Karol Sobiesiak
 
Introducing to number system
Introducing to number systemIntroducing to number system
Introducing to number systemtcc_joemarie
 
Floating point representation
Floating point representation Floating point representation
Floating point representation SVisnuDharsini
 
Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"Ra'Fat Al-Msie'deen
 
RNN sharing at Trend Micro
RNN sharing at Trend MicroRNN sharing at Trend Micro
RNN sharing at Trend MicroChun Hao Wang
 
Ncp computer appls num sys3 pramod
Ncp computer appls  num sys3 pramodNcp computer appls  num sys3 pramod
Ncp computer appls num sys3 pramodNCP
 
Behind the Performance of Quake 3 Engine: Fast Inverse Square Root
Behind the Performance of Quake 3 Engine: Fast Inverse Square RootBehind the Performance of Quake 3 Engine: Fast Inverse Square Root
Behind the Performance of Quake 3 Engine: Fast Inverse Square RootMaksym Zavershynskyi
 
Binary Numbers
Binary NumbersBinary Numbers
Binary Numbersikjsamuel
 
The Lights Out Puzzle and Its Variations
The Lights Out Puzzle and Its VariationsThe Lights Out Puzzle and Its Variations
The Lights Out Puzzle and Its VariationsPengfei Li
 
Top schools in delhi ncr
Top schools in delhi ncrTop schools in delhi ncr
Top schools in delhi ncrEdhole.com
 

Was ist angesagt? (19)

Number system
Number systemNumber system
Number system
 
Computer arthtmetic,,,
Computer arthtmetic,,,Computer arthtmetic,,,
Computer arthtmetic,,,
 
Data types - things you have to know!
Data types - things you have to know!Data types - things you have to know!
Data types - things you have to know!
 
Floating Point Numbers
Floating Point NumbersFloating Point Numbers
Floating Point Numbers
 
Introducing to number system
Introducing to number systemIntroducing to number system
Introducing to number system
 
Floating point representation
Floating point representation Floating point representation
Floating point representation
 
Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"Logic Circuits Design - "Chapter 1: Digital Systems and Information"
Logic Circuits Design - "Chapter 1: Digital Systems and Information"
 
06 floating point
06 floating point06 floating point
06 floating point
 
Slide03 Number System and Operations Part 1
Slide03 Number System and Operations Part 1Slide03 Number System and Operations Part 1
Slide03 Number System and Operations Part 1
 
Number system 1
Number system 1Number system 1
Number system 1
 
Computer Number System
Computer Number SystemComputer Number System
Computer Number System
 
RNN sharing at Trend Micro
RNN sharing at Trend MicroRNN sharing at Trend Micro
RNN sharing at Trend Micro
 
Number system
Number systemNumber system
Number system
 
Ncp computer appls num sys3 pramod
Ncp computer appls  num sys3 pramodNcp computer appls  num sys3 pramod
Ncp computer appls num sys3 pramod
 
Behind the Performance of Quake 3 Engine: Fast Inverse Square Root
Behind the Performance of Quake 3 Engine: Fast Inverse Square RootBehind the Performance of Quake 3 Engine: Fast Inverse Square Root
Behind the Performance of Quake 3 Engine: Fast Inverse Square Root
 
Binary Numbers
Binary NumbersBinary Numbers
Binary Numbers
 
The Lights Out Puzzle and Its Variations
The Lights Out Puzzle and Its VariationsThe Lights Out Puzzle and Its Variations
The Lights Out Puzzle and Its Variations
 
Top schools in delhi ncr
Top schools in delhi ncrTop schools in delhi ncr
Top schools in delhi ncr
 
Number system
Number systemNumber system
Number system
 

Ähnlich wie Chpater 6

UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptxamudhak10
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptxamudhak10
 
Chapter 1 digital design.pptx
Chapter 1 digital design.pptxChapter 1 digital design.pptx
Chapter 1 digital design.pptxAliaaTarek5
 
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptxchapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptxSurendra Loya
 
01.number systems
01.number systems01.number systems
01.number systemsrasha3
 
ADE UNIT-III (Digital Fundamentals).pptx
ADE UNIT-III (Digital Fundamentals).pptxADE UNIT-III (Digital Fundamentals).pptx
ADE UNIT-III (Digital Fundamentals).pptxKUMARS641064
 
Logic Design 2009
Logic Design 2009Logic Design 2009
Logic Design 2009lionking
 
number system: Floating Point representation.ppt
number system: Floating Point representation.pptnumber system: Floating Point representation.ppt
number system: Floating Point representation.pptNARENDRAKUMARCHAURAS1
 
Floating point representation and arithmetic
Floating point representation and arithmeticFloating point representation and arithmetic
Floating point representation and arithmeticAvirajKaushik
 
IEEE floating point representation
 IEEE floating point representation IEEE floating point representation
IEEE floating point representationMaskurAlShalSabil
 
Pertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem BilanganPertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem Bilanganahmad haidaroh
 
03_NumberSystems.pdf
03_NumberSystems.pdf03_NumberSystems.pdf
03_NumberSystems.pdfvijayapraba1
 
digital-electronics.pptx
digital-electronics.pptxdigital-electronics.pptx
digital-electronics.pptxsulekhasaxena2
 
Chapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbersChapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbersMohammad Bashartullah
 
IEEE 754 Standards For Floating Point Representation.pdf
IEEE 754 Standards For Floating Point   Representation.pdfIEEE 754 Standards For Floating Point   Representation.pdf
IEEE 754 Standards For Floating Point Representation.pdfkkumaraditya301
 
Digital Electronics – Unit I.pdf
Digital Electronics – Unit I.pdfDigital Electronics – Unit I.pdf
Digital Electronics – Unit I.pdfKannan Kanagaraj
 

Ähnlich wie Chpater 6 (20)

UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
 
UNIT - I.pptx
UNIT - I.pptxUNIT - I.pptx
UNIT - I.pptx
 
2013 1
2013 1 2013 1
2013 1
 
Chapter 1 digital design.pptx
Chapter 1 digital design.pptxChapter 1 digital design.pptx
Chapter 1 digital design.pptx
 
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptxchapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
chapter1digitalsystemsandbinarynumbers-151021072016-lva1-app6891.pptx
 
DIGITAL ELECTRONICS.pptx
DIGITAL ELECTRONICS.pptxDIGITAL ELECTRONICS.pptx
DIGITAL ELECTRONICS.pptx
 
01.number systems
01.number systems01.number systems
01.number systems
 
ADE UNIT-III (Digital Fundamentals).pptx
ADE UNIT-III (Digital Fundamentals).pptxADE UNIT-III (Digital Fundamentals).pptx
ADE UNIT-III (Digital Fundamentals).pptx
 
Number System
Number SystemNumber System
Number System
 
Logic Design 2009
Logic Design 2009Logic Design 2009
Logic Design 2009
 
number system: Floating Point representation.ppt
number system: Floating Point representation.pptnumber system: Floating Point representation.ppt
number system: Floating Point representation.ppt
 
number system
number systemnumber system
number system
 
Floating point representation and arithmetic
Floating point representation and arithmeticFloating point representation and arithmetic
Floating point representation and arithmetic
 
IEEE floating point representation
 IEEE floating point representation IEEE floating point representation
IEEE floating point representation
 
Pertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem BilanganPertemuan 2 - Sistem Bilangan
Pertemuan 2 - Sistem Bilangan
 
03_NumberSystems.pdf
03_NumberSystems.pdf03_NumberSystems.pdf
03_NumberSystems.pdf
 
digital-electronics.pptx
digital-electronics.pptxdigital-electronics.pptx
digital-electronics.pptx
 
Chapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbersChapter 1 digital systems and binary numbers
Chapter 1 digital systems and binary numbers
 
IEEE 754 Standards For Floating Point Representation.pdf
IEEE 754 Standards For Floating Point   Representation.pdfIEEE 754 Standards For Floating Point   Representation.pdf
IEEE 754 Standards For Floating Point Representation.pdf
 
Digital Electronics – Unit I.pdf
Digital Electronics – Unit I.pdfDigital Electronics – Unit I.pdf
Digital Electronics – Unit I.pdf
 

Mehr von EasyStudy3

2. polynomial interpolation
2. polynomial interpolation2. polynomial interpolation
2. polynomial interpolationEasyStudy3
 
Chapter2 slides-part 2-harish complete
Chapter2 slides-part 2-harish completeChapter2 slides-part 2-harish complete
Chapter2 slides-part 2-harish completeEasyStudy3
 
Chapter 12 vectors and the geometry of space merged
Chapter 12 vectors and the geometry of space mergedChapter 12 vectors and the geometry of space merged
Chapter 12 vectors and the geometry of space mergedEasyStudy3
 
Chapter 5 gen chem
Chapter 5 gen chemChapter 5 gen chem
Chapter 5 gen chemEasyStudy3
 
Topic 4 gen chem guobi
Topic 4 gen chem guobiTopic 4 gen chem guobi
Topic 4 gen chem guobiEasyStudy3
 
Gen chem topic 3 guobi
Gen chem topic 3  guobiGen chem topic 3  guobi
Gen chem topic 3 guobiEasyStudy3
 
Gen chem topic 1 guobi
Gen chem topic 1 guobiGen chem topic 1 guobi
Gen chem topic 1 guobiEasyStudy3
 
Chapter1 f19 bb(1)
Chapter1 f19 bb(1)Chapter1 f19 bb(1)
Chapter1 f19 bb(1)EasyStudy3
 

Mehr von EasyStudy3 (20)

Week 7
Week 7Week 7
Week 7
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Week 6
Week 6Week 6
Week 6
 
2. polynomial interpolation
2. polynomial interpolation2. polynomial interpolation
2. polynomial interpolation
 
Chapter2 slides-part 2-harish complete
Chapter2 slides-part 2-harish completeChapter2 slides-part 2-harish complete
Chapter2 slides-part 2-harish complete
 
L6
L6L6
L6
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
2
22
2
 
Lec#4
Lec#4Lec#4
Lec#4
 
Chapter 12 vectors and the geometry of space merged
Chapter 12 vectors and the geometry of space mergedChapter 12 vectors and the geometry of space merged
Chapter 12 vectors and the geometry of space merged
 
Week 5
Week 5Week 5
Week 5
 
Chapter 5
Chapter 5Chapter 5
Chapter 5
 
Lec#3
Lec#3Lec#3
Lec#3
 
Chapter 16 2
Chapter 16 2Chapter 16 2
Chapter 16 2
 
Chapter 5 gen chem
Chapter 5 gen chemChapter 5 gen chem
Chapter 5 gen chem
 
Topic 4 gen chem guobi
Topic 4 gen chem guobiTopic 4 gen chem guobi
Topic 4 gen chem guobi
 
Gen chem topic 3 guobi
Gen chem topic 3  guobiGen chem topic 3  guobi
Gen chem topic 3 guobi
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
Gen chem topic 1 guobi
Gen chem topic 1 guobiGen chem topic 1 guobi
Gen chem topic 1 guobi
 
Chapter1 f19 bb(1)
Chapter1 f19 bb(1)Chapter1 f19 bb(1)
Chapter1 f19 bb(1)
 

Kürzlich hochgeladen

“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 

Kürzlich hochgeladen (20)

“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 

Chpater 6

  • 1. 1 1 Today: Floating Arithmetic (H&H 5.3) Next: Assembly Language Basics (H&H 6.1-6.2) Lecture Topics 2 Self-study Module #5 (this week) Project #5 (due no later than 10/3) Project #6 (due no later than 10/17) Exam #1 – Thursday, 10/10 Announcements
  • 2. 2 3 Thursday, 10/10 during lecture 18% of course grade Bring #2 pencils (multiple choice) Bring MSU ID One 8.5x11 note sheet allowed Old exam on course website Exam #1 4 Single precision: 32 bits (4 bytes) Double precision: 64 bits (8 bytes) IEEE-754 Floating Point Formats
  • 3. 3 5 value double precision single precision ----- ---------------- ---------------- +inf 7FF0000000000000 7F800000 +99.5 4058E00000000000 42C70000 +15.0 402E000000000000 41700000 +10.75 4025800000000000 412C0000 +10.5 4025000000000000 41280000 +10.0 4024000000000000 41200000 +3.3 400A666666666666 40533333 +3.25 400A000000000000 40500000 +3.0 4008000000000000 40400000 +2.1 4000CCCCCCCCCCCD 40066666 +1.5 3FF8000000000000 3FC00000 +1.25 3FF4000000000000 3FA00000 +1.0 3FF0000000000000 3F800000 +0.5 3FE0000000000000 3F000000 +0.25 3FD0000000000000 3E800000 +0.0 0000000000000000 00000000 -0.0 8000000000000000 80000000 6 Format: sign of fraction 1 bit biased exponent 11 bits fraction 52 bits Interpretation: +/- 1.fraction x 2(biased exponent – 0x3FF) Double Precision
  • 4. 4 7 Range of DP exponents: 111 1111 1111 Special (Infinity, NaNs) 111 1111 1110 Largest (+0x3FF or +1023) ... 100 0000 0001 +2 100 0000 0000 +1 011 1111 1111 +0 011 1111 1110 -1 011 1111 1101 -2 ... 000 0000 0001 Smallest (-0x3FE or -1022) 000 0000 0000 Special (Zero, Denormals) 8 Format: sign of fraction 1 bit biased exponent 8 bits fraction 23 bits Interpretation: +/- 1.fraction x 2(biased exponent – 0x7F) Single Precision
  • 5. 5 9 Range of SP exponents: 1111 1111 Special (Infinity, NaNs) 1111 1110 Largest (+0x7F or +127) ... 1000 0001 +2 1000 0000 +1 0111 1111 +0 0111 1110 -1 0111 1101 -2 ... 0000 0001 Smallest (-0x7E or -126) 0000 0000 Special (Zero, Denormals) 10 Four categories of special values: Infinity Not-A-Number Zero Denormal Values All other values called “normalized” Special Values
  • 6. 6 11 Biased exponent field all ones Infinity – fraction field all zeroes 7FF0000000000000 NaN – fraction field not all zeroes 7FF0000000000001 Sign bit can be 1 (for negative); set of 253 different representations of NaN 12 Biased exponent field all zeroes Zero – fraction field all zeroes 0000000000000000 Denormal – fraction field not all zeroes 0000000000000001 Sign bit can be 1 (for negative); set of 253 different denormal values
  • 7. 7 13 Denormal values are smaller than the minimal normalized value – they allow us to have values which are close to zero. Normalized: 1.fraction x 2(Biased-0x3FF) Denormal: 0.fraction x 2-0x3FE All double precision denormal values have the same true exponent (-0x3FE or -1022) Denormal (Subnormal) Values 14 Assume only 6 bits available (artificial). Format: sign of fraction 1 bit biased exponent 2 bits fraction 3 bits Interpretation: +/- 1.fraction x 2 (biased exponent – 0x1) 6-bit Precision
  • 8. 8 15 Range of exponents: 11 Special (Infinity, NaNs) 10 Largest (+0x1 or +1) 01 Smallest (+0x0 or +0) 00 Special (Zero, Denormals) Set of positive and negative values symmetric (just like SP and DP formats) Clearly artificial, but able to enumerate all possibilities 16 Infinity and NaNs (8 bit patterns) encoding binary value decimal value -------- ------------------- ------------- 011111 NaN 011110 NaN 011101 NaN 011100 NaN 011011 NaN 011010 NaN 011001 NaN 011000 Infinity
  • 9. 9 17 True Exponent of 1 (8 bit patterns) encoding binary value decimal value -------- ------------------- ------------- 010111 1.111e+1 (11.11) 3.75 010110 1.110e+1 (11.10) 3.50 010101 1.101e+1 (11.01) 3.25 010100 1.100e+1 (11.00) 3.00 010011 1.011e+1 (10.11) 2.75 010010 1.010e+1 (10.10) 2.50 010001 1.001e+1 (10.01) 2.25 010000 1.000e+1 (10.00) 2.00 18 True Exponent of 0 (8 bit patterns) encoding binary value decimal value -------- ------------------- ------------- 001111 1.111e+0 (1.111) 1.875 001110 1.110e+0 (1.110) 1.750 001101 1.101e+0 (1.101) 1.625 001100 1.100e+0 (1.100) 1.500 001011 1.011e+0 (1.011) 1.375 001010 1.010e+0 (1.010) 1.250 001001 1.001e+0 (1.001) 1.125 001000 1.000e+0 (1.000) 1.000
  • 10. 10 19 Zero and Denormals (8 bit patterns) encoding binary value decimal value -------- ------------------- ------------- 000111 0.111e+0 (0.111) 0.875 000110 0.110e+0 (0.110) 0.750 000101 0.101e+0 (0.101) 0.625 000100 0.100e+0 (0.100) 0.500 000011 0.011e+0 (0.011) 0.375 000010 0.010e+0 (0.010) 0.250 000001 0.001e+0 (0.001) 0.125 000000 Zero 20 encoding binary value decimal value -------- ------------------- ------------- 011111 NaN .. 011000 Infinity 010111 1.111e+1 (11.11) 3.75 .. (0.25) 010000 1.000e+1 (10.00) 2.00 001111 1.111e+0 (1.111) 1.875 .. (0.125) 001000 1.000e+0 (1.000) 1.000 000111 0.111e+0 (0.111) 0.875 .. (0.125) 000000 Zero
  • 11. 11 21 Floating Point Representation: N bits ==> 2N values Sign and magnitude system: half of values negative Infinity and NaNs: biased exponent field all 1’s Zero and Denormals: biased exponent field all 0’s 22 Floating Point Representation: Only sums of powers of 2 are representable ex: 25 + 23 + 2-1 + 2-3 + 2-7 + 2-12 Gap between adjacent values increases as you move away from Zero
  • 12. 12 23 Approximate ranges: single double max normal 3.4 x 10 38 1.8 x 10 308 min normal 1.2 x 10 -38 2.3 x 10 -308 min subnormal 1.4 x 10 -45 4.9 x 10 -324 Approximate significant digits: single 7 double 16 24 Problems with floating point values: Overflow – exponent too large to represent (map value to Infinity) Underflow – exponent too small to represent (map value to Zero) Loss of precision – value requires too many bits to represent (truncate and round)
  • 13. 13 25 Represent 4.0 in 6-bit format: 4.0 base 10 = 100.0 base 2 normalize: 1.000 x 2 2 base 2 exponent = 2, too large result: Infinity 26 Represent 0.0625 in 6-bit format: 0.0625 base 10 = 0.0001 base 2 normalize: 1.000 x 2-4 base 2 exponent = -4, too small result: Zero
  • 14. 14 27 Represent 2.3125 in 6-bit format: 2.3125 base 10 = 10.0101 base 2 normalize: 1.00101 x 2 1 round: 1.001 +0.000 (since next bit is 0) 1.001 exponent = 1, OK result: 2.25 base 10 28 Represent 3.875 in 6-bit format: 3.875 base 10 = 11.111 base 2 normalize: 1.1111 x 21 base 2 round: 1.111 +0.001 (since next bit is 1) 10.000 normalize: 1.000 (add 1 to exp) exponent = 2, too large (Infinity)
  • 15. 15 29 Typical operations: Addition Subtraction Multiplication Division Square root Floating Point Operations 30 Floating Point Addition / Subtraction Assume base 10, all values have 2 digits: 1.5 x 103 1.5 x 103 + 8.7 x 101 ==> + 0.087 x 103 ? 1.587 x 10 3 normalize: 1.587 x 103 round: 1.6 x 103
  • 16. 16 31 Assume base 10, all values have 2 digits: 8.6 x 10 3 0.86 x 10 4 + 9.4 x 10 4 ==> + 9.4 x 10 4 ? 10.26 x 10 4 normalize: 1.026 x 10 5 round: 1.0 x 105 32 Assume base 10, all values have 2 digits: 5.7 x 103 0.57 x 104 + 9.4 x 10 4 ==> + 9.4 x 10 4 ? 9.97 x 10 4 normalize: 9.97 x 10 4 round: 10.0 x 10 4 normalize: 1.00 x 10 5 round: 1.0 x 105
  • 17. 17 33 Assume base 10, all values have 2 digits: 8.2 x 10 4 8.2 x 10 4 + 7.5 x 10 1 ==> + 0.0075 x 10 4 ? 8.2075 x 10 4 normalize: 8.2075 x 10 4 round: 8.2 x 10 4 34 Assume base 10, all values have 2 digits: 6.5 x 107 6.5 x 107 - 8.2 x 10 6 ==> - 0.82 x 10 7 ? 5.68 x 10 7 normalize: 5.68 x 10 7 round: 5.7 x 10 7
  • 18. 18 35 Assume base 10, all values have 2 digits: 7.3 x 10 6 7.3 x 10 6 - 7.2 x 10 6 ==> - 7.2 x 10 6 ? 0.1 x 10 6 normalize: 1.0 x 10 5 round: 1.0 x 10 5 36 Patterson and Hennessy Floating point addition: Normalization may cause overflow or underflow. Rounding may produce an unnormalized result (must repeat the step to normalize).
  • 19. 19 37 Example: 1. Unpack fields 2. Insert leading ones 3. Compare exponents 4. Shift smaller exponent 5. Add mantissas 6. Normalize mantissa, adjust exponent 7. Round result 8. Pack fields 38 Circuit for addition
  • 20. 20 39 Floating Point Multiplication Assume base 10, all values have 2 digits: 2.5 x 10 3 * 1.3 x 104 3.25 x 10 7 normalize: 3.25 x 107 round: 3.3 x 107 40 Floating Point Multiplication Assume base 10, all values have 2 digits: 3.2 x 105 * 1.1 x 103 3.52 x 10 8 normalize: 3.52 x 108 round: 3.5 x 108
  • 21. 21 41 Floating Point Multiplication Assume base 10, all values have 2 digits: 3.5 x 10 5 * 4.0 x 105 14.00 x 10 10 normalize: 1.400 x 1011 round: 1.4 x 1011 42 Patterson and Hennessy Floating point multiplication: Normalization may cause overflow or underflow. Rounding may produce an unnormalized result (must repeat the step to normalize).
  • 22. 1 1 Today: Assembly Language Basics (H&H 6.1-6.2) Next: continued Lecture Topics 2 Project #6 (due no later than 10/17) Exam #1 – Thursday, 10/10 Announcements
  • 23. 2 3 Thursday, 10/10 during lecture 18% of course grade Bring #2 pencils (multiple choice) Bring MSU ID One 8.5x11 note sheet allowed Old exam on course website Exam #1 4 Major themes: • programming in C (using "gcc") • integer bitwise and shift operations • floating point arithmetic Library module (function “mult") Driver module (function "main") Project #6
  • 24. 3 5 // Union: same area of memory, two types union sp_item { float frep; unsigned irep; }; // Declare object of type "union sp_item" union sp_item num; // Work with type "float" num.frep = 24.5; // Work with both types printf( "%f %08x n", num.frep, num.irep ); 6 Communication among components is handled by a shared pathway called the system bus, which is made up of the data bus, the address bus, and the control bus. There is also a power bus, and some architectures may also have a separate I/O bus. Review: The System Bus Model
  • 25. 4 7 I/O module: handles all input and output (human oriented and secondary storage) Memory module: 2 32 bytes of RAM CPU module: Control Unit Integer Unit Floating Point Unit Coprocessor (optional) ARM Model 8 RAMControl Unit Integer Unit FP Unit CP ARM Microprocessor RAM: holds program -- machine instructions and data Control Unit: manages all other units Integer Unit: circuits for integer operations Floating Point Unit: circuits for floating point operations Coprocessor: specialized circuits (optional)
  • 26. 5 9 Manages the fetch-execute cycle, controls the other modules. Control Unit Registers (32 bits): PC – address of current instruction IR – bit pattern of current instruction ARM Control Unit 10 Fetch Phase: RAM[ PC ] IR Execute Phase: decode IR take appropriate action update PC (usually PC + 4 PC) ARM Fetch-Execute Cycle
  • 27. 6 11 Tightly coupled with Control Unit. Handles all integer calculations. Integer Unit Registers (32 bits): General purpose registers (r0 – r15) CPSR (current program status register): includes NZCV status bits ARM Integer Unit 12 Contents of the general-purpose registers (r0-r15), as well as CPSR at some instant: IU REGISTERS cpsr: 40000010 icc: 4 (-Z--) r00: 00000000 r04: 000219d4 r08: 0000000f r12: 000219d4 r01: ffffffff r05: 000219e8 r09: 00000017 r13: 000219d8 r02: 00000000 r06: 00000000 r10: 00000012 r14: 000219dc r03: 00000000 r07: 00000000 r11: 0000001d r15: 000103e8 ARM Integer Unit
  • 28. 7 13 ARM Data Manipulation Register File ALU RS1 RS2 RD 4 4 4 32 32 32 14 Let's look at a very simple C program and discuss the steps required to translate the program from C into ARM machine language, then load and execute that machine language program. Translation and Execution
  • 29. 8 15 <1 lemon: > cat simple.c int A = 12; int B = 27; int C = -1; int main() { C = A + B; return 0; } 16 The text file “simple.c” resides on disk. Run “gcc” to translate and link that program, creating the executable file “a.out” (which also resides on disk): <2 lemon: > gcc -Wall simple.c Load “a.out” to execute the program: have the operating system copy the contents of “a.out” into RAM, set the program counter to the first machine language instruction in the program, then let the fetch-execute cycle take over: <3 lemon: > a.out
  • 30. 9 17 The machine language instructions from “a.out” after the file is loaded into memory. Addresses are 32 bits: 0001040c Machine language instructions are 32 bits: e1a00003 000103e8: e52db004 000103ec: e28db000 000103f0: e59f3024 000103f4: e5932000 000103f8: e59f3020 000103fc: e5933000 00010400: e0823003 00010404: e59f2018 00010408: e5823000 0001040c: e1a00003 00010410: e24bd000 00010414: e49db004 00010418: e12fff1e 0001041c: 000205c0 00010420: 000205c4 00010424: 000205c8 18 The variables (and initial values) from “a.out” after the file is loaded into memory. Addresses are 32 bits: 000205c0 Variables of type “int” are 32 bits: 0000000c 000205c0: 0000000c 000205c4: 0000001b 000205c8: ffffffff
  • 31. 10 19 Outline for function "main": Get address of A Load value of A Get address of B Load value of B Add value of A, value of B Get address of C Store result at C 20 000103e8: e52db004 000103ec: e28db000 000103f0: e59f3024 000103f4: e5932000 000103f8: e59f3020 000103fc: e5933000 00010400: e0823003 00010404: e59f2018 00010408: e5823000 0001040c: e1a00003 00010410: e24bd000 00010414: e49db004 00010418: e12fff1e 0001041c: 000205c0 00010420: 000205c4 00010424: 000205c8 . . 000205c0: 0000000c 000205c4: 0000001b 000205c8: ffffffff Two segments: 0001xxxx: instructions 0002xxxx: data
  • 32. 11 21 000103e8: e52db004 push {fp} 000103ec: e28db000 add fp, sp, #0 000103f0: e59f3024 ldr r3, [pc, #36] 000103f4: e5932000 ldr r2, [r3] 000103f8: e59f3020 ldr r3, [pc, #32] 000103fc: e5933000 ldr r3, [r3] 00010400: e0823003 add r3, r2, r3 00010404: e59f2018 ldr r2, [pc, #24] 00010408: e5823000 str r3, [r2] 0001040c: e1a00003 mov r0, r3 00010410: e24bd000 sub sp, fp, #0 00010414: e49db004 pop {fp} 00010418: e12fff1e bx lr 0001041c: 000205c0 .word 0x000205c0 00010420: 000205c4 .word 0x000205c4 00010424: 000205c8 .word 0x000205c8 22 Each machine language instruction is 32 bits Fields within each machine language instruction identify: • specific operation • options • source operands • destination register ARM Machine Language
  • 33. 12 23 Express instructions in symbolic form, have software translate them into machine language instructions Instructions: text file Software: assembler Assembler reads text file (".s" file), outputs to binary file (".o" file) ARM Assembly Language 24 CSE Pi array: 22 ARM V7 systems ARM V7 characteristics • RISC design • Load-store architecture • addresses: 32 bits • address space: 2^32 = 4 GB • register file: 16 32-bit registers (r0-r15) • machine language instructions: 32 bits Summary: ARM microprocessor
  • 34. 13 25 Tightly coupled with Control Unit. Handles all integer calculations. Integer Unit Registers (32 bits): General purpose registers (r0 – r15) CPSR (current program status register): includes NZCV status bits ARM Integer Unit 26 ARM Data Manipulation Register File ALU RS1 RS2 RD 4 4 4 32 32 32
  • 35. 14 27 Data processing instructions (16): • bitwise (logical) instructions (4) • arithmetic (add/sub) instructions (6) • move instructions (2) • comparison (test) instructions (4) ARM Data Manipulation 28 Four instructions: • AND • ORR (inclusive or) • EOR (exclusive or) • BIC (bit clear) Three registers: result <== operand1 op operand2 Bitwise (logical) instructions
  • 36. 15 29 r0 <== r6 AND r7 and r0, r6, r7 e0060007 r1 <== r6 OR r7 orr r1, r6, r7 e1861007 Examples 30 r2 <== r6 XOR r7 eor r2, r6, r7 e0262007 r3 <== r6 AND NOT r7 bic r3, r6, r7 e1c63007 Examples
  • 37. 16 31 r0 r7r6AND assembly: and r0, r6, r7 machine language: e0060007 machine language in binary: 11100000000001100000000000000111 Decoding machine language 32 r1 r7r6ORR assembly: orr r1, r6, r7 machine language: e1861007 machine language in binary: 11100001100001100001000000000111 Decoding machine language
  • 38. 17 33 r2 r7r6EOR assembly: eor r2, r6, r7 machine language: e0262007 machine language in binary: 11100000001001100010000000000111 Decoding machine language 34 r3 r7r6BIC assembly: bic r3, r6, r7 machine language: e1c63007 machine language in binary: 11100001110001100011000000000111 Decoding machine language
  • 39. 18 35 Six instructions: • ADD • ADC (add with carry flag) • SUB • SBC (subtract with carry flag) • RSB (reverse subtract) • RSC (reverse subtract with carry flag) Three registers: result <== op1 op op2 Arithmetic (add/sub) instructions 36 r0 <== r6 + r7 add r0, r6, r7 e0860007 r1 <== r6 + r7 + carry flag adc r1, r6, r7 e0a61007 Examples
  • 40. 19 37 r2 <== r6 - r7 sub r2, r6, r7 e0462007 r3 <== r6 - r7 - NOT carry flag sbc r3, r6, r7 e0c63007 Examples 38 r4 <== r7 - r6 rsb r4, r6, r7 e0664007 r5 <== r7 - r6 - NOT carry flag rsc r5, r6, r7 e0e65007 Examples
  • 41. 20 39 r0 r7r6ADD assembly: add r0, r6, r7 machine language: e0860007 machine language in binary: 11100000100001100000000000000111 Decoding machine language 40 r2 r7r6SUB assembly: sub r2, r6, r7 machine language: e0462007 machine language in binary: 11100000010001100010000000000111 Decoding machine language
  • 42. 21 41 Two instructions: • MOV • MVN (move not) Two registers: result <== operand2 (operand1 is missing) Move instructions 42 r0 <== r7 mov r0, r7 e1a00007 r1 <== NOT r7 mvn r1, r7 e1e01007 Examples
  • 43. 22 43 r0 r7not used MOV assembly: mov r0, r7 machine language: e1a00007 machine language in binary: 11100001101000000000000000000111 Decoding machine language 44 r1 r7not used MVN assembly: mvn r1, r7 machine language: e1e01007 machine language in binary: 11100001111000000001000000000111 Decoding machine language
  • 44. 23 45 Each ARM machine language instruction is 32 bits wide (4 bytes) • Operation code: bits 24:21 • Destination register: bits 15:12 • Source register #1: bits 19:16 • Source register #2: bits 3:0 What are the other bits used for? Summary (so far) 46 Format: Data processing instructions
  • 45. 24 47 S bit: when the S bit is 1, NZCV condition code flags are updated by the instruction I bit: when I bit is 1, the second operand is an 8-bit immediate value (rather than a register) cond: will always be 1110 (for now) Data processing instructions 48 r10 <== r6 + r7 add r10, r6, r7 e086a007 r10 <== r6 + r7, update NZCV flags adds r10, r6, r7 e096a007 Example: S bit
  • 46. 25 49 r0 <== r6 + 1 add r0, r6, #1 e2860001 r0 <== r6 + 0xff add r0, r6, #0xff e28600ff Example: I bit 50 r0 0xffr6ADD I bit S bit assembly: add r0, r6, #0xff machine language: e28600ff machine language in binary: 11100010100001100000000011111111 Decoding machine language