n301/cs16basicmachinelangn301.tplt
Stored Program
The most fundamental characteristic of the Von Neumann architecture
A sequence of machine language instructions stored as binary values in memory
Task of the Control Unit to - fetch from memory the next instruction to be executed - decode it - execute it
Machine Language Instructions
Instructions that can be decoded and executed by the control unit of a computer
Operation code (op code) is a unique unsigned-integer code assigned to each machine language operation
Address field(s) - the memory addresses of the values on which this operation will work
Format
Typical Machine Language Format
Instruction Format
Assume the op code for ADD is a decimal 9
Cells X and Y correspond to addresses 99 and 100 (decimal)
op code
address 1
address 2
8 (bits)
16 (bits)
16 (bits)
Putting it all together
op code
address 1
address 2
00001001
0000000001100011
0000000001100100
Instruction Set
The set of all operations that can be executed by a processor
RISC - Reduced Instruction Set Computer - newer processors make instruction sets as small and as simple as possible
Instruction Groups
4 basic groups - data transfer - arithmetic - compare - branch
Data transfer
These operations that move information between or within the different components of the computer
All data transfer instructions follow the nondestructive fetch/destructive store principle
Contents of the source cell are never destroyed, only copied.
Contents of the destination cell are overwritten and its previous contents are lost
Example Data transfer
Operation
Meaning
LOAD X
Load register R with the contents of memory cell X
STORE X
Store the contents of register R into memory cell X
MOVE X, Y
Copy the contents of memory cell X into memory cell Y
Arithmetic
These are operations that caue the arithmetic/logic unit to perform computation.
Typically indluce arithmetic operations like + , - , * , / as well as logic operations such as AND, OR and NOT
Arithmetic Example
Operation
Meaning
ADD X, Y, Z
Add the contents of memory cell X to the contents of memory cell Y and put the result in memory cell Z (Three-address ihnstruction)
ADD X, Y
Add the contents of memory cell X to the contents of memory cell Y. Put the result into memory cell Y (two-address instruction)
ADD X
Add the contents of memory cell X to the contents of register R. Put the result into register R (one-address instruction)
Compare
These operations compare two values and set an indicator on the basis of the results of the compare
Most Von Neumann machines have a special set of bits inside the processor called condition codes and these bits are set by the compare operations
Compare Example
Operation
Meaning
COMPARE X, Y
Compare the contents of memory cell X to the contents of memory cell Y and set the condition codes accordingly
Condition
How the condition codes are set
CON (X) > CON (Y)
GT = 1
EQ = 0
LT = 0
CON (X) = CON (Y)
GT = 0
EQ = 1
LT = 0
CON (X) < CON (Y)
GT = 0
EQ = 0
LT = 1
Branch
The normal mode of operation of a Von Neumann machine is sequential
The branch instructions alter the normal sequential flow of control - based typically on the current settings of the condition codes
Branch is almost always proceded by either a compare instruction or some other instruction that sets the condition codes
Branch Example
Operation
Meaning
JUMP X
Take the next instruction unconditionally from memory cell X
JUMPGT X
If the GT indicator is a 1, take the next instruction from memory cell X. Otherwise, take the next instruction from the next sequential location
HALT
Stop program execution. Don't go on to the next instruction
Fetch/Execute
The task of the control unit is to fetch and execute instructions similar to what was shown in the previous slides
The control unit relies on two special registers to accomplish this: - Program Counter (PC) - Instruction Register (IR) - and on the Instruction Decoder Circuit
Sequence
The PC holds the address of the next instruction to be executed
The IR holds a copy of the instruction fetched from memory (holding both the op code and the addresses)
To determine what the instuction is, the op code portion must be decoded using the instruction decoder
Assembly Language
Developed by individuals programming on the first-generation computers - designed for people as well as computers
Today, assembly language viewed as low-level programming languages - which means they are closely related to the machine language
High-level languages
Because they are more user-oriented, they are not machine-specific, the use both natural language and mathemetical notation in design - BASIC - Pascal - C++ - Java
The Continuum of Programming Languages
Source Program
User written program
Translated into a machine language program - object program - carried out by the assembler (compiler)
Advantages of assembler
Use of symbolic operation codes rather than numeric ones
Use of symbolic memory addresses rather than numeric ones
Psuedo-operations that provide useful user-oriented services such as data generation
Translation/Load/Execute
Format
label:
op code mnemonic
address field
--comment
Label
Attached to any instruction or piece of data in the program
Becomes a permanent identification for this instruction or data, regardless of where it appears in the program or where it may be moved in memory
Name followed by a colon placed at the beginning of an instruction - BEGIN: LOAD X
Op code mnemonic
Allows the programmer to refer to op codes using the symbolic name rather than by a number - LOAD, ADD, STORE
Address field
Lets the programmer use symbolic addresses in addition to numeric addresses - JUMP 17
Comment
Helpful explanation added to the instuction by a programmer and intended for someone reading the program
Ignored during translation and execution
Instruction Set