Module A Introduction PDF
Module A Introduction PDF
Programming Computers
Information
Languages and C Compilers
Module A - Introduction
1/40
Objectives
Programming Computers
Accidents
Software Development
Hardware
Information
Fundamental Units
Representations
Addressing Information
Program Instructions
Module A - Introduction
2/40
Objectives
Languages and C Compilers
Programming Languages
Why C as a First Language?
Compiling C Programs
Some Notable Features
Module A - Introduction
3/40
Programming Computers
Introduce the art of software development
Module A - Introduction
4/40
Accidents
In May 2004, the Royal Bank of Canada informed the
public that some of its transactions had not been properly
reflected in its client balances. The bank faced a classaction suit for damages of $500 per customer and a
possible loss of $165 million in service fees.
In July 2004, the Canadian Imperial Bank of Commerce
reported that its computer system had been affected by
glitches. The system had double dipped about 60,000
personal lines of credit.
Module A - Introduction
5/40
Accidents
In June 1996, the European Space Agency Ariane 5
maiden rocket self-destructed after going out of
control because of a software error.
In October 1992, the computer aided dispatch
system of the London Ambulance Service started
malfunctioning. In one case, the ambulance
arrived 11 hours late at a stroke victim's house - 5
hours after the caller had made their own way to
the hospital.
Module A - Introduction
6/40
Accidents
To minimize such accidents, we build quality into the
software that we develop. We design it for, amongst
other features:
Usability
Correctness
Maintainability
Understandability
Modifiability
Portability
Module A - Introduction
7/40
Accidents
We achieve quality through
robust and user-friendly interfaces
structured programming
comprehensive testing
internal documentation
standards compliance
Module A - Introduction
8/40
Software Development
The programs that we develop are simulations
of solutions to stated problems.
The process includes problem analysis,
algorithm design, program coding, program
testing and program maintenance.
A program is a set of instructions that
computer hardware will execute.
Module A - Introduction
9/40
Software Development
Module A - Introduction
10/40
Module A - Introduction
11/40
Hardware
Module A - Introduction
12/40
Hardware
Central Processing Unit
Module A - Introduction
13/40
Hardware
Primary Memory
Primary memory holds the information accessed
by the CPU.
Primary memory is also volatile.
The popular term for primary memory is RAM
(Random Access Memory).
Module A - Introduction
14/40
Hardware
Devices
Include I/O devices such as a keyboard, a monitor
and a mouse
Storage devices such as a floppy drive, a hard
drive and a CD-ROM drive (secondary storage).
Each device interfaces with the system buses
through a device controller.
Module A - Introduction
15/40
Hardware
The most expensive and fastest memory registers - is reserved for the CPU.
CPU transfers information at less than 10
nanoseconds
primary memory transfers information at about 60
nanoseconds
a hard disk transfers information at about
12,000,000 nanoseconds
Module A - Introduction
16/40
Summary
Programming Computers
Accidents
Software Development
Hardware
Q&A
Module A - Introduction
17/40
Information
Summarize the low-level features of programming.
Module A - Introduction
18/40
Fundamental Units
John von Neumann selected binary (base 2)
digits as the EDVAC's fundamental unit.
The vast majority of modern computers
process and store information in binary digits.
We call a binary digit a bit.
Module A - Introduction
19/40
Fundamental Units
The fundamental
addressable unit of
primary memory is the
byte.
One byte consists of 2
nibbles. One nibble
consists of 4
consecutive bits.
Byte
Nibble
Nibble
Bit Bit Bit Bit Bit Bit Bit Bit
00000000 <- possibility 0
00000001 <- possibility 1
00000010 <- possibility 2
00000011 <- possibility 3
00000100 <- possibility 4
...
00111000 <- possibility 104
...
11111111 <- possibility 255
Module A - Introduction
20/40
Fundamental Units
The natural unit of the CPU is a word. A word
is the size of the general registers - the unit of
memory within the CPU.
Module A - Introduction
21/40
Representations
Hexadecimal Representation
Base 16: 0,1,..,9, A, B, C, D, E, F
Each hexadecimal digit represents 4 bits of
information.
The 0x prefix identifies the number as a
hexadecimal number: 0x5C
Module A - Introduction
22/40
Representations
Octal Representation
Base 8: 0,1,2,..,7
Set of 3 consecutive bits forms an octal digit
The prefix 0 identifies the number as an octal
number: 031
Module A - Introduction
23/40
Addressing Information
Each byte of primary memory has a unique
address, start from zero
Kilo or k (=1024): 1 Kilobyte = 1024 bytes
Mega or M (=1024k)
Giga or G (=1024M)
Tera or T (=1024G)
Peta or P (=1024T)
Exa or E (=1024P)
Module A - Introduction
24/40
Addressing Information
Addressible Memory
The maximum size of addressable primary
memory depends upon the size of the address
registers
Module A - Introduction
25/40
Program Instructions
Each program instruction consists of an
operation and operands
The CPU performs the operation on the values
stored as operands or on the values stored in
the operand addresses.
The addresses are either register names or
primary memory addresses
Module A - Introduction
26/40
Program Instructions
Assemblers
Module A - Introduction
27/40
Summary
Information
Fundamental Units
Representations
Addressing Information
Program Instructions
Q&A
Module A - Introduction
28/40
29/40
Programming Languages
Module A - Introduction
30/40
Programming Languages
5 generations:
Machine languages.
Assembly languages.
Third-generation languages. These are languages with
instructions that describe how a result is to be obtained
(C, Pascal, C++, Java).
Fourth-generation languages. These are languages with
instructions that describe what is to be done without
specifying how it is to be done (eg:SQL).
Fifth-generation languages are the closest to human
languages. They are used for artificial intelligence, fuzzy
sets, and neural networks (eg: Prolog, Matlab)
Module A - Introduction
31/40
Programming Languages
The higher the level, the closer to the human
languages and the further from native
machine languages
Each third generation language statement ~ 5-10
machine language statements.
Each fourth generation language ~ 30-40 machine
language statements.
Module A - Introduction
32/40
Module A - Introduction
33/40
C is English-like,
C is quite compact - has a small number of keywords,
A large number of C programs need to be maintained,
C is the lowest in level of the high-level languages,
C is faster and more powerful than other high-level
languages, and
The UNIX, Linux and Windows operating systems are
written in C and C++.
Module A - Introduction
34/40
Time to Run
0.18 seconds
2.7 seconds
Basic
10 seconds
35/40
Compiling C Programs
/* My first program
*/
/* p_1.c
*/
/* Author your name here... */
/* Date
*/
main()
{
printf("This is Programming Fundamental\n");
}
Module A - Introduction
36/40
5/16/2010
Module A - Introduction
37/40
Compiling C Programs
Standards
The most recent standard to which C compiler
writers try to adhere is ANSI/ISO 9899-1999 or
C99 for short.
If we write our source code to this standard or
even better the earlier C89, we can expect our
code to compile on most platforms.
Module A - Introduction
38/40
Whitespace
We use whitespace to improve program
readability and to display the structure of our
program's logic. C compilers ignore all whitespace
Module A - Introduction
39/40
Module A - Introduction
40/40
Summary
Languages and C Compilers
Programming Languages
Why C as a First Language?
Compiling C Programs
Some Notable Features
Q&A
Module A - Introduction
41/40