Week 1 – Summary CMPT 295
Binary and Hexadecimal
! Binary is base 2
“Symbols: 0,1
” Convention: 210 = 102 = 0b10
! Example: What is 0b110 in base 10? “0b110=1102 =(1¡Á22)+(1¡Á21)+(0¡Á20)=610
! Hexadecimal (hex, for short) is base 16 “Symbols? 0,1,2,3,4,5,6,7,8,9,A…,?B,C,D,E,F ” Convention: 1610 = 1016 = 0x10
! Example: What is 0xA5 in base 10? “0xA5=A516 =(10¡Á161)+(5¡Á160)=16510
1
Week 1 – Summary CMPT 295
Base Comparison
! Why does all of this matter?
” Humans think about numbers in base 10, but computers ¡°think¡± about numbers in base 2
” Binary encoding is what allows computers to do all of the amazing things that they do!
! You should have this table memorized by the end of the class
” Might as well start now!
Base 10
Base 2
Base 16
0
0000
0
1
0001
1
2
0010
2
3
0011
3
4
0100
4
5
0101
5
6
0110
6
7
0111
7
8
1000
8
9
1001
9
10
1010
A
11
1011
B
12
1100
C
13
1101
D
14
1110
E
15
1111
F
2
Week 1 – Summary CMPT 295
Hardware: 295 View (version 1) instructions
take 300
CPU
! We will start by learning about Memory
How does a program find its data in memory?
Memory
data
registers
3
Week 1 – Summary CMPT 295
64-bit example Addresses and Pointers (pointers are 64-bits wide)
big-endian
! An address is a location in memory
! A pointer is a data object that holds an address
” Address can point to any data
Address
! Value 504 stored at
address 0x08 0x08
0x00 “504 =1F8 0x10
00
00
00
00
00
00
01
F8
00
00
00
00
00
00
00
08
10 16 0x18 = 0x 00 … 00 01 F8 0x20
0x28
0x30 0x38 points to 0x38
! Pointer stored at
address 0x08
0x40 0x48
4