Title: System Software
1System Software
- Making von Neumann Friendly
2The Naked Machine
- Von Neumann hard to work with
- Binary numbers everywhere
- Have to tell the computer where to start
- User Interface
- Hide messy details of HW from user
- Present info in form not requiring CS degree
- Easy user access to resources
- Prevent/repair accidental damage to HW, programs
data
3Virtual Machine
- Describing SW not HW
- No System Software circuit build from AND, OR
NOT gates - Automobile is similar
- HW Engine, power train, etc
- For most, HW a pain. Just want to drive
- Interface (SW) dashboard steering wheel
4System Software
- Operating System
- Communicates with user
- Determines what user wants
- Activates required SW
5Types of System Software
Operating System
Language Translators
Information Managers
Utilities
Editor, Graphics Etc.
Assemblers Compilers
File System Data Bases
Memory Managers
Scheduler
Linkers Loaders
6Writing a Program
- Use editor to create source for program P
- Use file system to store source on hard disk
- Use compiler to translate to machine code
- Use loader to allocate enough memory to hold
machine code put into memory - Use scheduler to run the program
- Use file system from program to store output in
data file - If program failed, use debugging utility to
locate problem.
7Programming the Computer
- Whats wrong with machine code?
- Uses binary
- No English-like words (or even math)
- Only numeric addresses (hard to keep track of)
- Difficult to change (entering binary is a pain!)
- Difficult to create data (you have to convert
everything yourself.
8Assembler
- First language translator
- Early 1950s
- Second generation computers
- Not as frequently used because of newer high
level languages like BASIC, Fortran, COBOL, C,
JAVA and C - More later in the course
9Programming a Computer
Source
Editor
Assembler
Errors
Machine Code
Loader
In RAM
Results
Hardware
10The Assembler
- Each line in an Assembler program has the same
format
Label Opcode Address --Comment
Used if you want To JUMP here
Symbolic Address (Label)
Like ADD, COMPARE, JUMPGT, etc.
11The Pseudo-Ops
- Used to generate data values instead of having to
convert the values to binary ourselves
X .data 7
Value being stored in X
Label or Symbolic Address
Pseudo-Op to Create a Data Value
12The Pseudo-Ops
- Where the program begins and ends
- .begin First line of assembler program
- .end Last line of assembler program
13An Example
.begin LOAD FIRST ADD SECOND STORE
ANSWER HALT FIRST .data 2 SECOND .data 4 ANSWE
R .data 0 .end
14Lets try a few
- Suppose we want to enter three numbers and add
them up. Well call our three numbers A, B, C.
15First Problem
.begin IN A -- Enter three numbers IN B IN C
LOAD A -- Get first number ADD B -- Add
second number ADD C -- Add third number STORE
ANS -- Store Answer OUT ANS -- Output
Result HALT A .data 0 B .data 0 C .data
0 ANS .data 0 .end
16Your Turn
- You try it with the calculation
- RESULT (A B) (C D)
17My Solution
.begin IN A -- Enter four numbers IN B IN C IN
D LOAD A -- Get first number ADD B -- Add
second number STORE TMP -- Store AB LOAD C --
get third number ADD D -- Add fourth
number STORE TMP2 -- Store CD LOAD TMP --
Get AB SUB TMP2 -- Subtract CD STORE ANS --
Store Answer OUT ANS -- Output Result HALT
A .data 0 B .data 0 C .data 0 D .data
0 ANS .data 0 TMP .data 0 TMP2 .data 0 .end
18How about an If-Then-Else
- If A gt B Then
- Output A
- Else
- Output B
19A Solution
.begin IN A -- Enter two numbers IN B LOAD B
-- Compare A and B COMP A JUMPGT ABIG -- A gt
B OUT B JUMP DONE ABIG OUT A DONE HALT A .da
ta 0 B .data 0 .end
20Your Turn
- If First gt Second Then
- Diff First Second
- Else
- Diff Second First
- Output Diff
21A Solution
.begin IN FIRST -- Enter two numbers IN SECOND
LOAD SECOND -- Compare numbers COMP
FIRST JUMPGT BIG1 -- First gt
Second LOAD SECOND -- Diff 2 nd-1
st SUB FIRST STORE DIFF JUMP DONE BIG1 LOAD F
IRST -- Diff 1 st - 2 nd SUB SECOND STORE DI
FF DONE OUT DIFF -- Output difference HALT FIR
ST .data 0 SECOND .data 0 DIFF .data 0 .end
22And a While Loop
- Twos 1
- While Twos lt 16000 Do
- Output Twos
- Twos Twos Twos
23A Solution
.begin WHILE LOAD TWOS -- Compare TWOS
32000 COMPARE END JUMPLT DONE -- TWOS gt 16000
Done! OUT TWOS -- Output twos
power LOAD TWOS -- Double the value in
Twos ADD TWOS STORE TWOS JUMP WHILE -- Go
back for another pass DONE HALT TWOS .data
1 -- Starting Twos value END .data 16000 --
Biggest Value .end
24Your Turn
- Sum 0
- Input a value
- While the value ? 0 Do
- Add the value to the Sum
- Input a value
- Output Sum
25My Solution
.begin IN VALUE -- Get a value WHILE
LOAD VALUE -- Compare Value 0 COMPARE
ZERO JUMPGT DONE -- Value lt 0
Done! LOAD SUM -- Sum Sum
Value ADD VALUE STORE SUM IN VALUE -- Get A
Value JUMP WHILE -- Go back for another
pass DONE OUT SUM -- Output the
sum HALT SUM .data 0 -- Starting Sum
value ZERO .data 0 -- Zero value VALUE .data 0
-- Input value .end