Introduction to Computing CPSC 203 January 24, 2006 Heejin Lim Chapter 1 Chapter 2 (part of)
Block diagram of a typical computer Main memory Secondary memory
Memory in a computer is made up of a lot of switches, each of which can be ON or OFF. Each switch represents one binary digit (bit) A byte is a group of 8 bits, which is used to measure the capacity of a memory e.g.) 256 MB, 40 GB Computers work in Binary, that is "Base 2" arithmetic We normally work in Decimal (Base 10) arithmetic 101 = 1* * *10 0 = = 101 Binary number system
’s place 2’s place 4’s place 8’s place 2 3 * * *1 + 1*1 = = 11 (decimal)
We usually write binary in hexadecimal (hex) or "Base 16“ for simple representation. Each digit is exactly 4 bits. In hexadecimal, we need fifteen numbers to represent any number: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F e.g.) 560, AB, FF => to decimal = 5* * *16 0 AB 16 = 10* *1 = => ? => ? 2 On a 32 bit computer a cell is typically a word = 4 bytes (unit to represent a number). One byte is always 8 bits. Addresses (memory locations) are typically byte addresses.
Base 2 => Base can be written as which, from the table, equals D94F in hexadecimal (or 55,631 in decimal).
PROGRAM test ! Test program Integer:: i, j REAL:: x, y character:: a i = 4 j = 5 x = 4.5 y = 5.5 a = 'G' WRITE(*,*) i+j WRITE(*,*) x+y WRITE(*,*) a STOP END PROGRAM test Declaration Section Execution Section Termination Section