Title: IPC144 - Session2
1IPC144 Session 2 Computer Organization, Problem
Analysis and Program Design
1
2- Objectives
- By the end of this session, the student will be
able to - List the first three stages of the evolution of
computer languages - Compare the three stages from a programmer's
point of view - List other 3GL languages
- Construct Boolean Logic Charts
- Apply Boolean Logic to problems
- List the steps in a model Systems Development
Life Cycle - Describe the purpose of each of the model steps
- List the 7 steps of a model Program Development
Cycle - Describe the purpose of each step of the PDC
- List the steps that occur when compiling a
computer program
4
3Software
- Software
- Software is a set of instructions that cause the
computer to perform specific tasks in a specific
order, and make simple decisions about the data
it encounters. The software must be written by
people in order to be supplied to the computer.
The software is written in a specialized
language. - There have been many generations of computer
languages - machine language
- assembly language
- high-level language (3GL)?
- very high-level language (4GL)?
- natural language
5
4Software, continued
- Machine Language Software
- This software is in the language of the
processor. This language is not easily readable
by humans as it consists of numbers only. - The instructions will consist of
- op-codes (operation codes) and,
- operands (sometimes)?
- Op-codes
- The op-codes are fetched and decoded by the
Control Unit, and executed by the ALU. - Operands
- The operands are either scalar data (a fixed
number, such as 5) or a memory address where data
is stored. These are also fetched by the Control
Unit for use by the ALU.
6
5Software, Continued
Machine language for Motorola 6809 (8-bit
CPU)? 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D
0E 0F 10 11 12 4F 97 13 96 12 27 09 4A 97 12 96
13 9B 11 20 F1 3E 02 05 address op-code operand d
ata The above program multiplies two numbers by
repeated addition. i.e. 5 x 2 2 2 2 2
2
7
6Software, Continued
Assembly language This is a small step forward.
The numeric instructions from machine language
have been replaced by mnemonics. This makes the
programs must easier to read, however it still
takes patience and a disciplined approach. There
are some pockets of assembly programming that
still exist. The mnemonics are designed for each
individual processor, however there are some
mnemonics that you may see from processor to
processor. These mnemonics are not understood by
the computer, so a simple program, called an
Assembler, converts the mnemonics to numbers,
and ultimately you end up with machine
language. The advantage of assembly is that the
programs written are very compact and run very
fast.
8
7Software, Continued
Assembly language for Motorola 6809 (8-bit
CPU)? 0000 4F CLRA 0001 97 13 LOOP STA
_at_13 0003 96 12 LDA _at_12 0005 27 09 BEQ
DONE 0007 4A DECA 0008 97 12 STA
_at_12 000A 96 13 LDA _at_13 000C 9B 11 ADD
_at_11 000E 20 F1 BRA LOOP 000F 3E DONE HLT 00
11 02 0012 05 0013 Address Machine
Language (output from assembler)? Assembly
Language (written by programmer)?
9
8Software, continued
High-level language There are many high-level
languages that exist. In these languages, the
programmer is using something that almost passes
as a human language. However, programs written
in these languages must be converted to machine
language. The advantage to these languages is
that there are relatively easy to learn, although
you might not believe me when we start talking
about C. The disadvantage is that the machine
code that is generated is not as optimized as
code written directly in machine language. These
languages are not specific to a particular
processor- therefore they are easily transported
from processor to processor.
10
9Software, continued
High-level language, continued The assembly
program in C How it would actually be written
in C i 5 i 5 j 2 j 2 k
0 k i j while (i gt 0)? k k
j i--
11
10Software, continued
- High-level language, continued
- Other 3GL languages
- TAL (for Tandem computers)?
- Turing (developed by University of Toronto, to
teach well structured programming)? - COBOL (a language for business applications)?
- FORTRAN (FORmula TRANslation - scientific and
engineering applications)? - PASCAL (a simple well structured language)?
- BASIC (a simple initially unstructured language
for learning programming)?
12
11Boolean Logic
13
12Boolean Logic
Boolean logic Developed by George Boole in the
19th century. A form of logical algebra, as
opposed to mathematical algebra. We are
concerned with TRUE or FALSE values instead of
numbers. Sometimes the digits 1 and 0 or the
letters T and F are used to represent the values
of TRUE and FALSE respectively. The algebra will
consist of statements that can be evaluated to
being either TRUE or FALSE 'Today is Saturday'
- FALSE 'You are in a lecture' - TRUE 'You are
asleep in the lecture' - ??
14
13Boolean Logic, continued
Boolean logic, continued The expressions being
evaluated will be mathematical expressions in
this course 5 6 a gt b a 4 lt c - 1 These
expressions will evaluate to either TRUE or FALSE
depending on the algebraic value of the
variables. a gt b would be TRUE if 'a' was 5 and
'b' was 4. a gt b would be FALSE if 'a' was 4 and
'b' was 5. We can now take the results of the
expressions and apply Boolean operators to them.
15
14Boolean Logic, continued
- Truth Tables
- The Boolean algebra is summarized in 'Truth
Tables'. There are two sections to the Truth
Table - Conditions
- Result
- Conditions
- There are 1 or more columns in the Conditions
section, depending on the number of possible
combinations of TRUE and FALSE being tested. - 1 column 2 possible conditions
- 2 columns 4 possible conditions
- 3 columns 8 possible conditions
- n columns 2n possible conditions
- Result
- The result column will contain only 1 possible
outcome for each condition, the result will be
either TRUE or FALSE.
16
15Boolean Logic, continued
Boolean NOT operator The Boolean NOT operator
simply reverses the values of TRUE and FALSE.
There is only one possible column in the
conditions section Examples
(assuming x is TRUE, y is FALSE) NOT x result
is FALSE NOT y result is TRUE NOT (5 lt
6) result is FALSE
17
16Boolean Logic, continued
Boolean OR operator The Boolean OR (also known as
Inclusive-OR) looks for any conditions that
contains at least one TRUE value Ex
amples (assuming x is TRUE, y is FALSE) x OR
y result is TRUE y OR y result is FALSE x OR
x result is TRUE (7 gt 8) OR (1 lt 2) result is
TRUE
18
17Boolean Logic, continued
Boolean OR operator, continued An extended OR
Truth Table
19
18Boolean Logic, continued
Boolean AND operator The Boolean AND looks for
any conditions that contain all TRUE
values Examples (assuming x is
TRUE, y is FALSE) x AND y result is FALSE y
AND y result is FALSE x AND x result is
TRUE (7 gt 8) AND (1 lt 2) result is FALSE
20
19Boolean Logic, continued
Boolean AND operator, continued An extended AND
Truth Table
21
20Boolean Logic, continued
Boolean Exclusive-OR operator The Boolean XOR
looks for any conditions that contain an odd
number of TRUE values Examples
(assuming x is TRUE, y is FALSE) x XOR
y result is TRUE y XOR y result is FALSE x
XOR x result is FALSE (7 gt 8) XOR (1 lt
2) result is TRUE
22
21Boolean Logic, continued
Boolean XOR operator, continued An extended XOR
Truth Table
23
22Boolean Logic, continued
Order of Precedence Just as in mathematics, you
have an order of precedence when calculating an
expression. What is the result of 5 22 x 2 /
4 (7 6 x 7) - 2 x 7 In Boolean Algebra, the
order of precedence, (unless overridden by
brackets) is perform NOT operations
first, followed by AND operations, followed by
XOR operations, followed by OR. Just like
multiplication is transitive in Mathematics, the
Boolean AND, OR and XOR are transitive. a x b x c
c x b x a b x a x c c x a x b b x c x a
a x c x b a b c c b a b a c c
a b b c a a c b What is the Truth
Table for a AND b XOR c? a AND b XOR NOT
c OR b?
24
23Boolean Logic, continued
Order of Precedence What is the Truth Table
for a AND b XOR c?
25
24Boolean Logic, continued
Order of Precedence What is the Truth Table
for a AND b XOR NOT c OR b?
26
25Boolean Logic, continued
Exercises 1) What is the Truth Table for a AND
NOT b OR NOT a AND b 2) TRUE AND FALSE OR NOT
FALSE Assuming the variables X, Y and Z have
been assigned the values 5, 7 and 12
respectively, what is the result (TRUE or FALSE)
of the following expressions 3) X 5 4) X lt
Y 5) X Y gt Z 6) (X gt 5) OR (Y gt 5)? 7) NOT (X
5)? 8) (X Y gt Z) AND (Z lt 24) OR NOT (Y lt
3)? 9) Create an expression that will result in
TRUE when any of the variables (A, B, C) are
greater than 0. A, B, C can be any number,
positive, negative, fractional. 10) Create an
expression that will result in FALSE only when
all three variables (A, B, C) are equal to 0) A,
B, C can be any number, positive, negative,
fractional.
27
26Boolean Logic, continued
Exercises 1) What is the Truth Table for a AND
NOT b OR NOT a AND b - see XOR table 2) TRUE AND
FALSE OR NOT FALSE - TRUE Assuming the variables
X, Y and Z have been assigned the values 5, 7 and
12 respectively, what is the result (TRUE or
FALSE) of the following expressions 3) X 5 -
TRUE 4) X lt Y - TRUE 5) X Y gt Z - FALSE 6) (X gt
5) OR (Y gt 5) - TRUE 7) NOT (X 5) - FALSE 8) (X
Y gt Z) AND (Z lt 24) OR NOT (Y lt 3) - TRUE 9)
Create an expression that will result in TRUE
when any of the variables (A, B, C) are greater
than 0 - (Agt0) OR (Bgt0) OR (Cgt0)? 10) Create an
expression that will result in FALSE only when
all three variables (A, B, C) are equal to 0) -
NOT (A0) OR NOT(B0) OR NOT (C0)?
28
27Systems Development Life Cycle
29
28Systems Development Life Cycle
- Background
- As systems become more complex, and businesses
become more reliant on computers, means to
structure the way new software is delivered is
needed. There are two aspects that will be
discussed - System Development Life Cycle
- Program Development Cycle
- The Program Development Cycle is a subset of the
System Development Life Cycle. - The following slides will provide an overview of
SDLC and PDC. The section on PDC will be
investigated closer for the remainder of the
course.
30
29Systems Development Life Cycle
- System Development Life Cycle
- The steps of the System Development Life Cycle
are - Analyse System
- Define System Requirements
- Design New System
- Develop New System
- Accept New System
- Implement System
- These steps are guidelines, and are not cast in
stone. Each company will have some variation of
these steps. There may be more steps, or some
steps will be combined.
31
30Systems Development Life Cycle
- SDLC Analyse System
- Performed on existing manual systems as well as
existing automated systems - Performed by System Analyst
- Most effectively performed by interviewing the
users - Identify what is done, and how
- Identify any problems with current system
- Go-No Go Decision based on ROI estimates
32
31Systems Development Life Cycle
- SDLC Define System Requirements
- What changes are required
- System Analyst works with Business Analyst
- Develop 'look and feel' of new system
- Determine what needs to be done (not how)?
- Every input, output and process is documented
- Output reports, screen designs
- Input what data, where does it come from
- Process what activities are required to produce
the output - Go-No Go Decision
33
32Systems Development Life Cycle
- SDLC Design New System
- Define all programs, files, databases, manual
processes - System Flowcharts are a common tool
- Like a program flowchart
- Major inputs
- Major outputs
- Inter-relationships between entities in system
- No details as to how the programs work
34
33Systems Development Life Cycle
- SDLC Develop New System
- Involves designing, coding and unit-testing
- Uses Program Development Cycle
- Goal is high-quality well structured programs
- Main focus of the remainder of this course
35
34Systems Development Life Cycle
- SDLC Accept New System
- Performed by Business user or Representative who
has intimate knowledge of Business functionality
of the system - Entire system is tested to ensure it conforms to
the System Requirements (Phase 2)? - Assumes no knowledge of internal workings of
system - System documentation reviewed
- Implementation strategies discussed
- Users trained
36
35Systems Development Life Cycle
- SDLC Implement New System
- When the new system is implemented into the
production environment - Evaluation of new system (comparison between the
expected objectives and the actual results)? - Results of the evaluation may become the input to
a subsequent SDLC
37
36Program Development Cycle
38
37Program Development Cycle
- Program Development Cycle
- The steps of the Program Development Cycle are
- Define the Problem
- Outline the Solution
- Develop the Solution into an Algorithm
- Test the Algorithm for Correctness
- Code the Program into a Specific Language (C)?
- Run the Program on the Computer
- Document and Maintain the Program
- These steps are guidelines, and are not cast in
stone. Each company will have some variation of
these steps. There may be more steps, or some
steps will be combined.
39
38Program Development Cycle
- PDC Define the Problem
- Must have a clear understanding of the problem
- There is no room for assumptions
- There is no difference between solving the wrong
problem correctly and solving the right problem
incorrectly - To help with analysis, the problem should be
broken into - Inputs
- Outputs
- Processes
- IPO Charts are a tool used
40
39Program Development Cycle
- PDC Outline the Solution
- Break problem into smaller tasks or steps
- Create a rough draft of the solution, may include
- Major processing steps
- Major sub-tasks (if any)?
- Major control structures (repetition loops)?
- Major variables and record structures
- Mainline logic of the program
- Top-down design
- Modularity and Hierarchy charts are tools used
41
40Program Development Cycle
- PDC Develop the Outline into an Algorithm
- Computers cannot devise a plan or decide to act
- Computers can only do what they are told, exactly
the way they are told - Computers do what you tell them to do, not what
you want them to do - An algorithm is a set of precise instructions
which describe the task to be performed and the
order in which they are to be carried out - Flowcharts and Pseudocode are tools to be
discussed
42
41Program Development Cycle
- PDC Test the Algorithm for Correctness
- One of the most important steps
- Identifies major logic errors
- Walkthroughs are a technique for testing
- Test plans are used to document and plan the
tests necessary to prove your algorithm performs
as required
43
42Program Development Cycle
- PDC Code the Program
- Performed only after previous design
considerations have been complete - In this course the C language will be used,
although these techniques can be used for any
language (Fortran, COBOL, BASIC, Pascal, Turing,
TAL...)? - Unfortunately, this is where many people begin
PDC or SDLC
44
43Program Development Cycle
- PDC Run the Program
- Most will find this the most rewarding step
- This step involves the compiler, which will
identify syntax errors and some basic
coding/logic errors - Further testing takes place against a Test Plan
- Can be very frustrating if the design and testing
is incomplete before the coding is performed - May need to be performed several times
45
44Program Development Cycle
- PDC Document and Maintain Program
- Documentation is an ongoing task throughout the
PDC - External Documentation
- Internal Documentation
- Maintenance takes place during the life of the
program, due to - Enhancements (new functionality, new
requirements)? - Bugs
46
45Compile Process
47
46Compile Process
Compile Process As mentioned, a high-level
language must be converted to machine language.
This process is referred to as compiling the
program. The program is a file that contains
instructions written in the high-level language.
It is used as data to the compiler, which
generates machine language.
48
47Compile Process
Compile Process The compile process starts by
taking the source file (the file containing the
high-level instructions) and converts it into an
object file. The object file contains some
machine language and some points that additional
code needs to be attached to. The object file is
linked into the operating system, and the final
result is an executable file containing the
machine language instructions ready to run.
Compiler
Translator
Linker
Object File
Source file (3GL Language Text File)?
Executable file
Library files (for O/S)?
49