Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

Lecture 1.1.

2 (System bus organization, Machine language program execution –


instruction cycles, machine cycles and bus cycles)
System Buses:
 A bus is a set of wires.
 To send information from one component to other, the source component outputs
data onto the bus and the destination component receives that data.
 As the complexity increases, it becomes more efficient to use buses rather than
direct connection b/w pair of devices.
 Bus uses space and power.
 They also require less pins on the chip.

System bus organization


Bus Organization: A bus organization is a group of conducting wires which carries
information, all the peripherals are connected to a microprocessor through the bus. A system
bus is nothing just a group of wires to carry bits.
The MPU (Micro Processing Unit) performs primarily four operations:
 Memory Read: Read data (or instructions) from memory.
 Memory Write: Write data (or instructions) into memory.
 I/O Read: Accepts data from I/P devices.
 I/O Write: Sends data to O/P devices.
The diagram to represent the bus organization of the 8085 microprocessor is given below:

Types of Bus in the microprocessor are:


i. Address Bus
ii. Data Bus
iii. Control Bus
Address Bus:
The address bus carries information about the location of data in the memory. The addresses
bus is unidirectional because of data flow in one direction, from the microprocessor to
memory or from the microprocessor to input/out devices. The length of the Address bus of
8085 microprocessor is 16 bit (That is, four hexadecimal digits), ranging from 0000H to
FFFF H. The microprocessor 8085 can transfer a maximum of 16-bit addresses which means
it can address 65,536 different memory locations i.e. 64KB memory.
Address Bus is used to perform the first function, identifying a peripheral or a memory
location.
Data Bus:
The data bus allows data to travel between the microprocessor (CPU) and memory (RAM).
The data bus is bidirectional because of data flow in both directions, from the microprocessor
to memory or input/output devices and from memory or input/output devices to
microprocessors. The length of the Data bus of 8085 microprocessor is 8 bit (that is, two
hexadecimal Digits0, ranging from 00H to FFH.
The data bus is used to perform the second function, transferring binary information.
Control Bus: It is used by CPU for communicating with other devices within the computer.
 Control bus carries the commands from the CPU and returns status signals from the
devices.
 Lines:
o Read (R’) – single line that when active (at 0) indicates that device is being read
by the CPU.
o Write (W’) - single line that when active (at 0) indicates that device is being
written by the CPU.
o ACK: It delivers information that data was acknowledged by the device.
o Bus request: Indicates that the device is requesting to access the bus.
o Reset: reset the system.
o Clock Signals: The signals on this line are used to synchronise data between the
CPU and a device.
o Control Bus is bidirectional.

The control bus carries the control signals to control all the associated peripherals, the
microprocessor uses control bus to process data, that is what to do with selected memory
location signals are:
o memory card
o memory write
o input/output, write

Advantages of buses:

 New elements can be easily added.


 Low cost.
 Reduce complexity.

Disadvantages of buses:
 Creates a communication bottleneck.
 Maximum speed is limited by
 Length of the bus
 No of devices on the bus
Machine language program execution
Machine Language: "Machine language is the basic low-level programming language
designed to be recognized by a computer. The language is written in a binary code of 0s and
1s that represent electric impulses or off and on electrical states respectively. A group of such
digits is called an instruction and it is translated into a command that the central processing
unit or CPU understands." Sometimes machine language referred to as machine code or
object code, machine language is a collection of binary digits or bits that the computer reads
and interprets. Machine language is the only language a computer is capable of
understanding.
The exact machine language for a program or action can differ by operating system on the
computer. The specific operating system will dictate how a compiler writes a program or
action into machine language. Computer programs are written in one or more programming
languages, like C++, Java, or Visual Basic. A computer cannot directly understand the
programming languages used to create computer programs, so the program code must be
compiled. Once a program's code is compiled, the computer can understand it because the
program's code has been turned into machine language.
For example: Machine language (binary) for the text "Hello World"
01001000 01100101 01101100 01101100 01101111 00100000 01010111 01101111
01110010 01101100 01100100
Example of binary machine language is the binary- coded decimal, where decimal numbers
are encoded in binary form. Each decimal digit is coded as a four- digit binary number as
follows:
• 0000 = 0
• 0001 = 1
• 0010 = 2
• 0011 = 3
• 0100 = 4
and so on
For example, the decimal number 5,270 is represented by the binary code for 5, 2, 7, 0, which
translates into 0101 0010 0111 0000.
The CPU has the ability to perform millions of instructions per second and this fact makes the
binary machine language efficient, despite the volume of bits. It would be useful to note that
different CPUs from different manufacturers use different machine languages.
Program Execution:
The process by which a computer machine performs the instructions of a computer program
is known as program execution. Execution in computer and software engineering is the
process by which a computer or a virtual machine performs the instructions of a computer
program. The instructions in the program trigger sequences of simple actions on the
executing machine. Those actions produce effects according to the semantics of the
instructions in the program. Programs for a computer may execute in a batch process without
human interaction, or a user may type commands in an interactive session of an interpreter. In
this case the "commands" are simply programs, whose execution is chained together.
The instructions in the program perform simple actions on the executing machine. Those
actions result according to the semantics of the instructions in the program. Little number of
programs are executable on a bare machine. Operating system helps most of the programs to
execute and run- time libraries specific to the source language that provide crucial services
not supplied directly by the computer itself. Program execution can be divided in three
categories.
• Compiler
• Interpreter
• Assembler
Compiler: A compiler is a software program that transforms high-level source code that is
written by developer in a high-level programming language into a low-level object code
(binary code) in machine language, which can be understood by the processor. The process of
converting high-level programming into machine language is known as compilation. The
processor executes object code, which indicates when binary high and low signals are
required in the arithmetic logic unit of the processor.
Compilers that produce the object code meant to run on a system are called cross-compilers.
Finally, a compiler that converts one programming language into another is called a language
translator. Interpreter: An interpreter is a computer program that is used to directly execute
program instructions written using one of the many high-level programming languages. The
interpreter transforms the high-level program into an intermediate language that it then
executes, or it could parse the high-level source code and then performs the commands
directly, which is done line by line or statement by statement. It means, the interpreter reads
each statement of code and then converts or executes it directly. Since an interpreter reads
and then executes code in a single process, it is very useful for scripting and other small
programs. As such, it is commonly installed on Web servers, which run a lot of executable
scripts.
Program Execution in the CPU
It contains a special register — the instruction register — whose bit pattern determines what
the central processor unit can do. Once that action has been completed, the bit pattern within
the instruction register may be modified, and also the central processor unit can perform the
operation nominative by this next bit pattern.
Since directions are simply bit patterns, they will be kept in memory. The instruction pointer
register continuously has the memory address of (points to) the next instruction to be
executed. so as for the management unit to execute this instruction, it’s derived into the
instruction register. the case is as follows:
1. A sequence of instructions is stored in memory.
2. The memory address wherever the first instruction is found is copied to the instruction
pointer.
3. The CPU sends the address within the instruction pointer to memory on the address
bus.
4. The CPU sends a “read” signal to the control bus.
5. Memory responds by sending a copy of the state of the bits at that memory location
on the data bus, that the CPU then copies into its instruction register.
6. The instruction pointer is automatically incremented to contain the address of the next
instruction in memory.
7. The CPU executes the instruction within the instruction register.
8. Go to step 3
Steps 3, 4, and 5 are called an instruction fetch. Notice that steps 3 – 8 constitute a cycle, the
instruction execution cycle. It is shown graphically below:
Instruction cycle:
i. The time a microprocessor needs to fetch and execute one entire instruction is known
as an instruction cycle.
ii. There are typically four stages of an instruction cycle that the CPU carries out-
iii. Fetching the instruction: The next instruction is fetched from the memory address
that is currently stored in the program counter (PC) and stored in the instruction
register (IR). At the end of the fetch operation, the PC points to the next instruction
that will be read at the next cycle.
iv. Decode the instruction: During this cycle the encoded instruction present in the IR
(instruction register) is interpreted by the decoder.
v. Read the effective address: In case of a memory instruction (direct or indirect) the
execution phase will be in the next clock pulse. If the instruction has an indirect
address, the effective address is read from main memory and any required data is
fetched from main memory to be processed and then placed into data registers (Clock
Pulse: T3). If the instruction is direct, nothing is done at this clock pulse. If this is an
I/O instruction or a Register instruction, the operation is performed (executed) at
clock Pulse.
vi. Execute the instruction: The control unit of the CPU passes the decoded information
as a sequence of control signals to the relevant function units of the CPU to perform
the actions required by the instruction such as reading values from registers, passing
them to the ALU to perform mathematical or logic functions on them and writing the
result back to a register. If the ALU is involved, it sends a condition signal back to the
CU. The result generated by the operation is stored in the main memory or sent to an
output device. Based on the condition of any feedback from the ALU, Program
Counter may be updated to a different address from which the next instruction will be
fetched.
Machine Cycle
The steps performed by the computer processor for each machine language instruction
received. The machine cycle is a four-process cycle that includes reading and interpreting the
machine language, executing the code, and then storing that code.

Four steps of the machine cycle


1. Fetch - Retrieve an instruction from memory.
2. Decode - Translate the retrieved instruction into computer commands.
3. Execute - Execute the computer commands.
4. Store - Send and write the results back in memory.
Example of a machine cycle
Below is an example of a machine cycle performing the steps mentioned above for a math
problem.
1. The computer user enters a math problem that's stored in memory. The computer
fetches that instruction from memory.
2. The control unit decodes that math problem into instructions the computer
understands.
3. The ALU executes the instructions to get the answer to the math problem.
4. The problem's answer is sent to and stored in memory where it can be accessed
and displayed to the user.
Improvements with pipelining
Early computer processors needed to wait until an instruction completed all four stages
before beginning work on the next instruction. However, today's computers use pipelining,
which allows the processor to begin fetching a second instruction before it has completed the
machine cycle for another instruction.
MACHINE INSTRUCTIONS
Machine Instructions are commands or programs written in machine code of a machine
(computer) that it can recognize and execute.
 A machine instruction consists of several bytes in memory that tells the processor to
perform one machine operation.
 The processor looks at machine instructions in main memory one after another, and
performs one machine operation for each machine instruction.
 The collection of machine instructions in main memory is called a machine language
program.
Machine code or machine language is a set of instructions executed directly by a computer’s
central processing unit (CPU). Each instruction performs a very specific task, such as a load,
a jump, or an ALU operation on a unit of data in a CPU register or memory. Every program
directly executed by a CPU is made up of a series of such instructions.
The general format of a machine instruction is
[Label:]                 Mnemonic      [Operand, Operand]                  [; Comments]

 Brackets indicate that a field is optional


 Label is an identifier that is assigned the address of the first byte of the instruction in
which it appears. It must be followed by “:”
 Inclusion of spaces is arbitrary, except that at least one space must be inserted; no space
would lead to an ambiguity.
 Comment field begins with a semicolon “ ; ”
 
Example:
Here:                 MOV      R5, #25H                 ; load 25H into R5
 
MACHINE LANGUAGE PROGRAM EXECUTION
 
A computer executes machine language programs mechanically -- that is without
understanding them or thinking about them -- simply because of the way it is physically put
together. This is not an easy concept. 
A computer is a machine built of millions of tiny switches called transistors, which have the
property that they can be wired together in such a way that an output from one switch can
turn another switch on or off. As a computer computes, these switches turn each other on or
off in a pattern determined both by the way they are wired together and by the program that
the computer is executing. 
Machine language instructions are expressed as binary numbers. A binary number is made up
of just two possible digits, zero and one. So, a machine language instruction is just a
sequence of zeros and ones. Each particular sequence encodes some particular instruction. 
The data that the computer manipulates is also encoded as binary numbers. A computer can
work directly with binary numbers because switches can readily represent such numbers:
Turn the switch on to represent a one; turn it off to represent a zero. 
Machine language instructions are stored in memory as patterns of switches turned on or off.
When a machine language instruction is loaded into the CPU, all that happens is that certain
switches are turned on or off in the pattern that encodes that particular instruction. The CPU
is built to respond to this pattern by executing the instruction it encodes; it does this simply
because of the way all the other switches in the CPU are wired together.
 
WHAT HAPPENS DURING INSTRUCTION EXECUTION?
 

Table -1.2.1
 
INSTRUCTION REPRESENTATION
 
Table - 1.2.2
 
INSTRUCTION CYCLE

A program residing in the memory unit of the computer consists of a sequence of


instructions. The program is executed in the computer by going through a cycle for each
instruction. Each instruction cycle in turn is subdivided into a sequence of sub cycles or
phases. In the basic computer each instruction cycle consists of the following phases:
1. Fetch an instruction from memory.
2. Decode the instruction.
3. Read the effective address from memory if the instruction has an indirect address.
4. Execute the instruction.
Upon the completion of step 4, the control goes back to step 1 to fetch, decode, and execute
the next instruction. This process continues indefinitely unless a HALT instruction is
encountered.

Fig. 1.2.1 Instruction cycle


BUS CYCLE
The bus cycle is the cycle or time required to make a single read or write transaction between
the cpu and an external device such as external memory.

MACHINE CYCLE
 
The machine cycle is the amount of cycles needed to do either a fetch, read or write
operation. more here. The read or write may be more than a single bus cycle if the transaction
between the CPU and memory is longer than the data width fetched or written. For example,
on an 8080 machine, the data width is 8 bits. If the CPU needs to fetch or write 16 bits of
data,  that will require two bus cycles.
HOMEWORK  (ASSESMENT)
Q1. A basic instruction that can be interpreted by computer has
A. Operand and opcode 
B. Decoder and Accumulator
C. Sequence register and decoder            
D. None of the above
Answer: A
Q2. In generic microprocessor instruction time is
A. Shorter than machine cycle time          
B. Larger than machine cycle time
C. Ten times machine cycle time                                
D. Exactly same as machine cycle time
Answer: D
Q3. In a program using subroutine call instruction, it is necessary
A. initialise program counter 
B. Clear the accumulator 
C. Reset the microprocessor 
D. Clear the instruction register
 Answer: D

References
Reference Books:
 J.P. Hayes, “Computer Architecture and Organization”, Third Edition.
 Mano, M., “Computer System Architecture”, Third Edition, Prentice Hall.
 Stallings, W., “Computer Organization and Architecture”, Eighth Edition, Pearson
Education.
Text Books:
 Carpinelli J.D,” Computer systems organization &Architecture”, Fourth Edition,
Addison Wesley.
 Patterson and Hennessy, “Computer Architecture” , Fifth Edition Morgaon Kauffman.
Reference Website
 https://www.geeksforgeeks.org/computer-organization-and-architecture-tutorials/
 Machine Language and Program Execution | Blablawriting.com
 What is Machine Language - javatpoint
 https://www.eventhelix.com/RealtimeMantra/FaultHandling/bus_cycles.htm
 https://stackoverflow.com/questions/10383354/difference-between-machine-cycle-
bus-cycle-and-execution-cycle#:~:text=The%20bus%20cycle%20is%20the,more
%20here.
 https://www.geeksforgeeks.org/machine-instructions/
 http://www.ddegjust.ac.in/studymaterial/msc-cs/ms-07.pdf
 https://www.cs.helsinki.fi/group/nodes/kurssit/tikra/2010s/luennot/luento-06_p2.pdf

Video References

 https://www.youtube.com/watch?v=Z5JC9Ve1sfI
 https://www.youtube.com/watch?v=8b1Cs1Uf6hI

You might also like