0% found this document useful (0 votes)
6 views19 pages

COSC323 Module 3

Uploaded by

tr9rphcwbp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views19 pages

COSC323 Module 3

Uploaded by

tr9rphcwbp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

COSC 323

Microprocessor
Organization &
Introduction to
Programming languages
Microprocessor Organization & Introduction to Programming languages

Outline:

 Basic Microprocessor Structure and Function


 Machine Language
 Low-Level Language
 High-Level Language
Microprocessor Organization & Introduction to Programming languages

Specific Objectives:

By the end of this module, you should be able:


 Describe the Processor Organizations and explain the
internal components.
 Expatiate on how the sequential algorithm of the CPU
execute each basic instruction.
 Explain machine language, assembly language and high
level language.
 State advantages and disadvantages of machine
language, assembly language and high level language.
Understanding the Processor Organizations
Processor Organization
The requirements placed on the processor or what it must do are:
• Fetch instruction: The processor reads an instruction from memory (register, cache, main memory).
• Interpret instruction: The instruction is decoded to determine what action is required.
• Fetch data: The execution of an instruction may require reading data from memory or an I/O module.
• Process data: The execution of an instruction may require performing some arithmetic or logical
operation on data.
• Write data: The results of an execution may require writing data to memory or an I/O module.

To do these things:
• The processor needs to store some data temporarily.
• It must remember the location of the last instruction so that it can know where to get the next instruction.
• It needs to store instructions and data temporarily while an instruction is being executed.
• The processor needs a small internal memory known as the register to temporarily store instruction as
depicted in the next figure
Arithmetic Logic Unit (ALU)

ALU has two main functions which are as follows:


• It performs arithmetic operations such as additions, subtractions, divisions and multiplications as
the name suggests on a given set of data.

• All logical operations such as comparison of two sets of data based on specified relationships like
greater than, less than, equal or greater than, equal or less than, equal to, etc and given
parameters are carried out by this unit.

Therefore;
• It is required that these data are fetched from the memory by ALU under the directive of the Control Unit at the
beginning of every operation of ALU.
• First, the data fetched is deposited into a register called Memory Data Register (MDR), which is located within
ALU Later the same data is stored in another data registers called the Accumulators, which are also located
within ALU.
• Prior to the above process (normally referred to as Loading Data), the address of the data item would have
been fetched from the Instruction Register (IR) to be located on Memory Address Register (MAR).

The complete process of how ALU carries out its functions is shown in the flow chart below
When the results of the operation of
ALU are still required for further
processing;
• They are temporarily stored in
data registers located within ALU
hardware such as OPERAND,
RESULT.

• Otherwise, the results are sent to


the main memory or computer
output.

• When the result is sent to the


main memory, the process is
called storing data.

• Every step of ALU’s operations is
directed by the Control Unit
Fig 7.2: Flow Chart for ALU’s Functions
Control Unit

The chief commander of any computer is its Control Unit (CU)

• It is the nerve center of computer responsible for directing all computer operations from the inputs
to the outputs.
• No part of the computer hardware can function without a prior instruction/command from CU.
• By so doing, the functions of every part of the computer are coordinated and synchronized just like
the human body parts function in agreement with one another.
• It determines what to do by interpreting the instructions and appoints which hardware does what
is required.
Computer is made to carry out its functions step-by-step
through organized instructions, which are loaded into the
main memory.

• The instruction to be executed is transferred one-by-one


from the main memory to the Instruction Register, IR via
the Memory Address Register (MAR).

• This happens when the main memory receives a signal


from CU indicating the address of the instruction in the
Memory Address Register (MAR) which is then moved as
instructed.

• The instruction in IR is interpreted by the Control Unit.


The result of this interpretation causes CU to command
the appropriate hardware to execute the instruction.

• This process is repeated for the next instruction until the


fetch-execution cycle is completed.

• A register called Program Counter (PC) holds the address


of the next instruction to be executed and for every
Fig 7.3: Flow Chart for CU’s Functions instruction fetched, the content of PC is increased by one..
The Register

The registers in the processor perform two roles:


• User-visible registers: Enable the machine- or assembly language programmer to minimize main
memory references by optimizing use of registers. These are:
 General purpose
 Data
 Address
 Condition codes
• Control and status registers: Used by the control unit to control the operation of the processor and by
privileged, operating system programs to control the execution of programs. These are:
 Program counter (PC): Contains the address of an instruction to be fetched
 Instruction register (IR): Contains the instruction most recently fetched
 Memory address register (MAR): Contains the address of a location in memory
 Memory buffer register (MBR): Contains a word of data to be written to memory or the word
most recently read

These registers serve as input and output registers for the ALU and exchange data with the MBR and
user-visible registers.
Bus Systems

A Computer Bus System is defined as a common pathway or channel between multiple devices. This
internal bus of a computer also known as the local bus, host bus, or processor bus provides a parallel data
transfer path between the CPU and main memory and to the peripheral buses

Three types of buses:


Address bus:
• Is used to transport the source and destination addresses of information transmitted on the data bus.
• Is also used to indicate memory locations generated by the microprocessor, bus master, or DMA.
• The number of lines available to the address bus determines the address space
Data bus:
• Is the internal pathway across which data is transferred to and from the processor or to and from memory.
• The width and speed of the data bus directly affects performance and significantly influence system
throughput.
• The width of the bus is usually equal to the number of data pins on the microprocessor.
Control bus:
• Is used to identify the type of bus cycle and indicate when the cycle is complete.
• Is used to carry control signals, such as those needed to determine whether a device will read or write data
and the operation being performed is to memory or I/O.
Learning how the sequential algorithm of the CPU execute each basic instruction

A typical sequential algorithm of how the CPU executes


each basic instruction are as follows:

i. Fetch the next instruction from memory into the


instruction register(IR)
ii. Change the program counter(PC) to point to the
following instruction
iii. Determine the type of instruction just fetched
iv. If the instruction uses a word in memory, determine
where it is
v. Fetch the word, if needed, into a CPU register
vi. Execute the instruction

Go to (i) to start executing the following (next)


instruction.
Introduction to Programming Languages

 A programming language is a tool or template through which


instructions are passed to computers
 Programmers write instructions in various programming languages,
some directly understandable by computers and others requiring
intermediate translation steps.
 Hundreds of computer languages are in use today. These can be
divided into three general types:
a. Machine Language
b. Low Level Language
c. High level Language
Machine Language
 Machine languages generally consist of strings of numbers (1s and 0s) that
instruct computers to perform their most elementary operations one at a
time.
 Machine language is the “natural language” of a computer and such is
defined by its hardware design.
 Machine languages are machine dependent (i.e a particular machine
language can be used on only one type of computer).
Advantages of Machine Language
i. It uses computer storage more efficiently
ii. It takes less time to process in a computer than any other
programming language
Disadvantages of Machine Language
i. It is time consuming
ii. It is very tedious to write
iii. It is subject to human error
iv. It is expensive in program preparation and debugging stages
Low Level Language

 In low level language, instructions are coded using mnemonics or


symbolic codes such as DIV, ADD, SUB, MOV.
 Assembly language is an example of a low level language.
 An assembly language implements a symbolic representation of the
numeric machine codes and other constants needed to program a
particular CPU architecture.
 The symbolic representation (called mnemonics) is usually defined
by the hardware manufacturer and help the programmers remember
individual instructions, registers, etc.
 An assembly language is thus specific to a certain physical or virtual
computer architecture (as opposed to most high-level languages,
which are usually portable).
 A utility program called an assembler is used to translate assembly
language statements into the target computer's machine code.
 Today, assembly language is used primarily for direct hardware
manipulation, access to specialized processor instructions, or to
address critical performance issues.
Low Level Language

Advantages of Low Level Language


i. It is more efficient than machine language
ii. Symbols make it easier to use than machine language
iii. It may be useful for security reasons

Disadvantages of Low Level Language


i. It is defined for a particular processor
ii. Assemblers are difficult to get
iii. Although, low level language codes are clearer to humans,
they are incomprehensible to computers until they are
translated to machine language.
High Level Language
 High level language allows programmers to write instructions that look
almost like everyday English and contain commonly used mathematical
notations.
 High level languages were developed in which simple statements could be
written to accomplish substantial tasks.
 Translator programs called compilers/interpreters convert high level
language programs into machine language.

Advantages of High Level Language


i. Compilers are easy to get.
ii. It is easier to use than any other programming language
iii. It is easier to understand compared to any other programming
language
Disadvantages of High Level Language
i. It takes more time to process in a computer than any other
programming language
Question: Mention at least 10 high level languages you known.
Why learn Assembly Language?

Our focus in this course is Assembly language

We learn Assembly Language program majorly for the following reasons

 If bugs have to be analyzed,


 If the program executes different than designed and expected,
 If the higher-level language doesn't support the use of certain hardware features,
 If time-critical in line routines require assembly language portions,
 If there is need for security
 Others are:
 Time-efficiency: Applications for which the execution speed is important fall under two categories:
a)Time convenience (to improve performance)
b)Time critical applications (to satisfy functionality)
 Accessibility to hardware
 Space-efficiency
Creating program in Assembler
To create a program in assembler different options exist
i. The DEBUGGER editor
ii. The TASM or Turbo Assembler, of Borland
iii. The MASM (Microsoft Assembler)
iv. NASM (Netwide Assembler); supports a varieties of format including Linux &
Microsoft windows.
v. Emu 8086 Assembler (Emulator 8086)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy