Lecture 1.1.2 (System Bus Organization, Machine Language Program Execution - Instruction Cycles, Machine Cycles and Bus Cycles)
Lecture 1.1.2 (System Bus Organization, Machine Language Program Execution - Instruction Cycles, Machine Cycles and Bus Cycles)
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:
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.
Table -1.2.1
INSTRUCTION REPRESENTATION
Table - 1.2.2
INSTRUCTION CYCLE
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