Вы находитесь на странице: 1из 9

WKU, CCI, IT

Computer Organization & Architecture (Ch-3)

3. Assembly level machine organization


3.1. Basic organization of the von Neumann machine
The von Neumann model of computer architecture was first described in 1946 by Burks,
Goldstein, and von Neumann (1946). All computers more or less based on the same basic design,
the von Neumann Architecture! The von Neumann architecture describes a general framework,
or structure, that a computer's hardware, programming, and data should follow.

Computer Components
Processor
ALU Input

Memory
AU LU

CU Output

1
WKU, CCI, IT
Computer Organization & Architecture (Ch-3)

Memory or RAM (Random Access Memory) consists of many memory cells (storage units) of a
fixed size. Each cell has an address associated with it: 0, 1 and each cell has two important
characteristics:
(1) Its address (where it is)
(2) Its contents (what’s stored at the given location)

3.2. Control unit - instruction fetch, decode, and execution.

The task of the control unit is to execute programs by repeatedly fetching, decoding, executing of
instruction until the HALT instruction is sent.
 Fetch - the process getting from memory the next instruction to be executed. Since
two instructions are fetched at once, the first step is to determine if a fetch from
memory is required
 Decode - it determines what is to be done. Decides which of the instructions will be
executed.
 Execute - it is doing the operation by issuing the appropriate signals to the ALU,
memory, and I/O subsystems to. After an instruction is executed, control returns to
the instruction fetch cycle.
3.3. Instruction sets and types (Data manipulation, Control, I/O)

Instruction sets are the complete collection of instructions that are understood by a CPU. It is a
group of bits that instruct the computer to perform a specific operation.

A computer should have a set of instructions so that the user can construct machine language
programs to evaluate any function that is known to be computable. The types of instructions
categories are the following:

1. Arithmetic, logical, and shift instructions - Arithmetic, logical, and shift instructions
provide computational capabilities for processing the type of data that the user may wish
to employ.
2. Instructions for moving information (from and to memory and registers). The bulk of
the binary information in a digital computer is stored in memory, but all computations are
2
WKU, CCI, IT
Computer Organization & Architecture (Ch-3)

done in processor registers. Therefore, there must be the capability of moving


information between these two units.
3. Program control instructions together with instructions that check status conditions.
They are decision making capabilities of digital computers. For example comparing two
numbers and proceeding differently based on the decision. Branching instructions are
used to change the sequence in which the program is executed.
4. Input and output instructions – They are needed for communication between the
computer and the user. Programs and data must be transferred into memory and results of
computations must be transferred back to the user.

Elements of an instruction are:-

 An opcode: Is short for 'Operation Code'. An opcode is a single instruction that can be
executed by the CPU. In machine language it is a binary or hexadecimal value such as 'B6'
loaded into the instruction register. In assembly language mnemonic form an opcode is a
command such as MOV, ADD or JMP.
 Operands: Are manipulated by the opcode. They are usually constant, labels, registers,
variables, constants or address.
Example: MOV AL, 34h

In this example, the opcode is the MOV instruction and the operands are the register named AL
and the value 34h hexadecimal.

Data manipulation:

 Arithmetic -
 Logical and bit manipulation -
 Shift instructions -
3.4. Assembly/machine language programming

A program is a list of instructions or statements for directing the computer to perform a required
data-processing task. There are various types of programming languages that one may write for a

3
WKU, CCI, IT
Computer Organization & Architecture (Ch-3)

computer, but the computer can execute programs only when they are represented internally in
binary form. Programs written in any other language must be translated to the binary
representation of instructions before they can be executed by the computer.

A machine language program is a binary program. Octal, hexadecimal representation and an


assembly language (symbolic instruction) can be considered to be a machine-level language.

Assembly Language
Assembly language is the symbolic form of machine language. They are written in short
abbreviations called mnemonics. The basic unit of an assembly language program is a line of
code. The specific language is defined by a set of rules that specify the symbols that can be used
and how they may be combined to form a line of code. Rules of an assembly language for
writing symbolic programs for the basic computer are:-
3.5. Instruction formats
 Label field - May be empty or specify a symbolic address.
 Instruction field – (Opcode and Operands) Specifies memory-reference instruction
(MRI), register-reference or input-output instruction (non-MRI) and pseudo-instruction
with or without an operand.
 Comment field - May be empty or it may include a comment. Provides a space for
documentation to explain what has been done for the purpose of debugging and
maintenance
A symbolic address specifies the memory location of an operand. It consists of one, two, or three
alphanumeric characters. The first character must be a letter; the next two may be letters or

4
WKU, CCI, IT
Computer Organization & Architecture (Ch-3)

numerals. The symbol can be chosen arbitrarily by the programmer. A symbolic address in the
label field is terminated by a comma.

A memory-reference instruction occupies two or three symbols separated by spaces. The first
must be a three-letter symbol defining an MRI operation code, the second is a symbolic address
and the third symbol, which may or may not be present, is the letter I. If “I” is missing, the line
denotes a direct address instruction and if present it denotes an indirect address instruction.

A non-MRI is defined as an instruction that does not have an address part. A non-MRI is
recognized in the instruction field of a program by any one of the three-letter symbols listed in
the table below.
Symbol Description
AND AND M to AC
ADD Add M to AC, carry to E
LDA Load AC from M
STA Store AC in M
BUN Branch unconditionally to m
BSA Save return address in m and branch to m + 1 (Branch and
Save Return Address)
ISZ Increment M and skip if zero
CLA Clear AC
CLE Clear E
CMA Complement AC
CME Complement E
CIR Circulate right E and AC
CIL Circulate left E and AC
INC Increment AC
SPA Skip if AC is positive
SNA Skip if AC is negative
SZA Skip if AC is zero
SZE Skip if E is zero
HLT Halt Computer
INP Input information and clear flag
OUT Output information and clear flag
SKI Skip if input flag is on
SKO Skip if output flag is on
ION Turn interrupt on
IOF Turn interrupt off
Table: Computer Instruction codes
The following shows symbols placed in the instruction field of a program.

5
WKU, CCI, IT
Computer Organization & Architecture (Ch-3)

Instruction Symbolic
code/symbol Address

Having an understanding of assembly language makes one aware of how programs interface with
OS, processor, and BIOS; how data is represented in memory and other external devices; how
the processor accesses and executes instruction; how instructions access and process data; how a
program accesses external devices.

Advantages of using assembly language are:-

 It requires less memory and execution time;


 It allows hardware-specific complex jobs in an easier way;
 It is suitable for time-critical jobs;
 It is most suitable for writing interrupt service routines and other memory resident
programs.

Pseudo-instruction
A pseudo-instruction is not a machine instruction but rather an instruction to the assembler
giving information about some phase of the translation. The ORG (origin) pseudo-instruction
informs the assembler that the instruction or operand in the following line is to be placed in a
memory location specified by the number next to ORG. It is possible to use ORG more than once
in a program to specify more than one segment of memory. The translation of the symbolic
program into binary is done by a special program called an assembler.

6
WKU, CCI, IT
Computer Organization & Architecture (Ch-3)

Example:
 Write an assembly language that adds content of memory location Y initialized to 350 and
memory location X initialized to 96. And store the result in location Z initialized to 0.
LD X \ AC  X
MOVAC \ DR  AC
LD Y \ AC  Y
ADD \ AC  AC + DR
ST Z \ Z  AC
STOP
X W 350 \ Reserve a word initiated to 350
Y W 96 \ Reserve a word initiated to 96
Z W 0 \ Result stored here

3.6. Subroutine call and return mechanisms

Frequently, the same piece of code must be written over again in many different parts of a
program. Instead of repeating the code every time it is advantageous if the common instructions
are written only once. A set of common instructions that can be used in a program many times is
called a subroutine. Each time that a subroutine is used in the main part of the program, a branch
is executed to the beginning of the subroutine. After the subroutine has been executed, a branch
is made back to the main program.
A subroutine consists of a self-contained sequence of instructions that carries out a given
task. A branch can be made to the subroutine from any part of the main program. This poses the
problem of how the subroutine knows which location to return to, since many different locations
in the main program may make branches to the same sub-routine. It is therefore necessary to
store the return address somewhere in the computer for the subroutine to know where to return.
Because branching to a subroutine and returning to the main program is such a common
operation, all computers provide special instructions to facilitate subroutine entry and return.

3.7. Input-Output Programming and interrupts

A computer communicates with the external environment. Instructions and data stored in
memory must come from some input device and results must be transmitted to the user through
some output device.

7
WKU, CCI, IT
Computer Organization & Architecture (Ch-3)

In this topic we will use a terminal unit with a keyboard and printer.
 The terminal sends and receives serial information of eight bits of an alphanumeric code.
 The serial information from the keyboard is shifted into the input register INPR.
 The serial information for the printer is stored in the output register OUTR.
These two registers communicate with a communication interface serially and with the AC in
parallel.
 The transmitter interface receives serial information from the keyboard and transmits it to
INPR.
 The receiver interface receives information from OUTR and sends it to the printer serially.
 The INPR instruction transfers the input information from INPR into the eight low-order bits
of AC and also clears the input flag to 0.
 The OUT instruction transfers the eight least significant bits of AC into the output register
OUTR and clears the output flag to 0.
 The next two instructions check the status of the flags and cause a skip of the next instruction
if the flag is I.
 The instruction that is skipped will normally be a branch instruction to return and check the
flag again.
 The branch instruction is not skipped if the flag is 0. If the flag is 1, the branch instruction is
skipped and an input or output instruction is executed.
 The last two instructions set and clear an interrupt enable flip-flop IEN. The purpose of IEN
is explained in conjunction with the interrupt operation.

8
WKU, CCI, IT
Computer Organization & Architecture (Ch-3)

Program Interrupt

A computer keeps checking the flag bit, and when it finds it set, it initiates an information
transfer. The difference of information flow rate between the computer and that of the input-
output device makes this type of transfer inefficient.

The alternative means is to let the external device inform the computer when it is ready for the
transfer. This type of transfer uses the interrupt facility. While the computer is running a
program, it does not check the flags. However, when a flag is set, the computer is momentarily
interrupted from proceeding with the current program and is informed of the fact that a flag has
been set and it deviates from what it is doing to take care of the input or output transfer and then
returns to the current program to continue what it was doing before the interrupt.

Вам также может понравиться