View
3
Download
0
Category
Preview:
Citation preview
Course Name: Computer Architecture and Assembly LanguageCourse ID: COMP233/L
Course Instructor: Mr. Ahmad JawdatLecture Notes
- Each character is stored inside a cell of bits.
A seven-bit cell
- Some possible values in a seven-bit cell
- Representation of Unsigned Integers:o Range for unsigned integers
In real world there is no limit to counting numbers. A real computer has a finite number of bits in each cell. There is a limit to the numbers that can be stored in a cell.
o The number 22 (dec) in a seven-bit cell
1 of 33
They do not affect the value of the number, but are necessary for specifying the content of the memory location
o The range of unsigned values depends on the number of bits in a cell. A sequence of all 0’s represents the smallest unsigned value.
000 0000 A sequence of all 1’s represents the largest.
111 1111 000 0000 (bin) = 0 (dec). 111 1111(bin) = 127 (dec).
o Unsigned addition: Similar to unsigned 1addition in the decimal system. Addition rules in binary system:
0 + 0 = 0 0 + 1 = 1 1 + 0 = 1 1 + 1 = 10
Carry technique: If two numbers in a column add to a value greater than 1
o 1 must be carried to the next column.o Example1:
01 1010 (bin) = 26 (dec) 01 0001(bin) = 17 (dec) 10 1011 (bin) = 43 (dec) 26 + 17 = 43
o Example 2:
o The Carry Bit: When adding two numbers in binary system, we are limited by the
number of bits in a cell. Sometimes the sum is too large to fit into the cell.
Six-bit cell range is 0 to 63 (dec). The CPU contains a special bit called the carry bit.
Denoted C.
2 of 33
01 101001 0001
ADD
10 1011
00 111101 1001
ADD
01 1000
When two binary numbers were added, if the sum of the left-most column (the most significant bit) produces a carry.
The C is set to 1. O/W
The C is cleared to 0.
o Examples:
In the second example the sum is equal to 68. Too large to fit into the six-bit cell.
- Two’s Complement Binary Representationo The unsigned binary representation works only for nonnegative integers.o So store a negative integers, we will have a two part cell.
One-bit sign to store the sign of the number. Is called the sign bit. 1 for negative and 0 for positive. The rest is to store the nonnegative number. Is called the magnitude.
o + 5(dec) = 0 00101 (bin)o - 5 (dec) = 1 00101 (bin)
o In decimal, when you add -5 to +5 you will get 0.
3 of 33
01 011010 0010
ADD
11 1000C = 0
10 101001 1010
ADD
00 0100C = 1
0 0 0 1 0 1
o Using the previously mentioned representation WE WILL NOT GET 0.
o It would be more convenient if the hardware of the CPU could add the numbers for +5 and -5 to get zero.
o The positive number has a 0 sign bit and a magnitude as in the unsigned binary representation.
+5 will be 00 0101. -5 will not be 10 0101
11 1011.o
o Under the rule of binary addition for a six-bit cell The number 11 1011 is called the additive inverse of 00 0101 The operation of finding the additive inverse is called negation,
NEG. Negating a number is called taking its two’s complement.
o Steps for taking the two’s complement of a number:1. Finding the one’s complement.
The binary number with all the 1’s changed to 0’s and all the 0’s changed to 1’s.
Is called the NOT operation.2. Adding one to the one’s complement.
o Example: Take the two’s complement of +5
o Solution: +5(dec) = 00 0101 (bin).1. One’s complement:
NOT 00 0101 = 11 10102. Adding one to the one’s complement
4 of 33
0 00101 0 00101
ADD
10 1010C = 0
00 0101 11 1011ADD00 0000C = 1
11 1010 00 0001ADD
11 1011C = 0
Therefore, -5 (dec) = 11 1011 (bin)
o General rule: The two’s complement of a number is 1 plus its one’s complement. NEG x = 1 + NOT x.
o Example: Take the two’s complement of -5.
o Solution:
NOT 11 1011 = 00 0100
Therefore, +5 (dec) = 00 0101 (bin)
- Two’s Complement Range:o Range of a four-bit cell system.
– There are only three bits are reserved for magnitude.– The greatest unsigned number to be stored is 0 111 (+7).
o The previous figure shows the two’ complement up to +7. It automatically produces 1 in the sign bit of the negative numbers. -5 is obtained from -6 by adding 1. -6 is obtained from -7 by adding 1. We can also obtain -7 by from -8 by adding one. We can not also obtained -8 by from -9 by adding one,
Because -9 can not be represented by a four-digit cell.o The full range for four-bit cell for signed integers is:
1000 to 0111, or -8 to +7.
5 of 33
00 010000 0001ADD
00 0101C = 1
o A general rule: Regardless of the number of bits in the cell,
The largest positive number is a single 0 followed by all 1’s.
The negative number with the largest magnitude is a single 1 followed by all 0’s.
o Its magnitude is one greater than the magnitude of the largest positive integer.
The number -1(dec) is represented as all 1’s Example:
The range for six-bit two’ complement representation is o 10 0000 to 01 1111, oro -32 to 31
Base conversion To convert a negative number from decimal to binary is a
two-step process.1. Convert its magnitude from decimal to binary as in
unsigned binary representation.2. Negate it by taking the two’s complement.
Example: for -7 (dec) in a 10-bit cell.1. +7 (dec) = 00 0000 01111 (bin)2. NOT 00 0000 0111 = 11 1111 1000
o So -7 (dec) is 11 1111 1001 (bin)
To convert a number from binary to decimal in a computer that uses two’s complement representation, always check the sign bit first.
o If it is 0, the number is positive:
6 of 33
11 1111 100000 0000 0001ADD
11 1111 1001
Convert as in unsigned representation.o If it is 1, the number is negative:
1. Make the number positive by negating it.2. Convert it to decimal as in unsigned
representation. Example:
o You have a 10 bit cell that contains 11 1101 1010. What decimal number does it represent?
Solution:o The sign is 1, therefore it is negative.o Negate the number:
NOT 11 1101 1010 = 00 0010 0101
o 00 0010 0110 (bin) = 38 (dec). Therefore,o 11 1101 1010 (bin) = -38 (dec)
- The Overflow Bito The hardware does not make distinction between the two types of data
representation Unsigned and Two’s complement.
o When adding the content of two memory cells, the CPU uses the rules for binary addition on the bit sequences, regardless of their types.
In unsigned representation, if the sum is out of range: The hardware stores the incorrect result, and Set the carry but (C) to 1. It’s up to the software to examine the C bit after the
addition has been made, and take the appropriate action.o In the two’s complement the C bit no longer indicates whether a sum is in
range or out of range.o An overflow condition occurs when the result of an operation in out of
range. To flag this condition for signed numbers, the CPU contain another
special character called the overflow bit, V. When adding two numbers and the result is interpreted to two’s
complement, If it’s out of range the V is set to 1. O/W is set to cleared, set to 0.
7 of 33
00 0010 010100 0000 0001ADD
00 0010 0110
Again it’s up to the software to check the V bit, and take the appropriate actions.
o The software inspects the signs of the numbers and the sum. If you add two positives and get a negative sum, or if you add two
negatives and get a positive sum: You have got an overflow. It is not possible to get an overflow by adding a positive and a
negative.o The Negative and Zero bits
The software tests the special bits to perform some operations: C bit to detect overflow condition in unsigned integers. V bit to detect overflow condition in signed integers.
There are also other bits that are used for similar purposes: N bit to detect a negative result. Z bit to detect a Zero result.
N bit: N = 1 if the result is negative. N = 0 O/W.
8 of 33
Adding two positives 00 001101 0101ADD
01 1000V = 0C = 0
01 011000 1100ADD
10 0010V = 1C = 0
Adding a positive and a negative
00 010111 0111ADD
11 1100V = 0C = 0
00 100011 1010ADD
00 0010V = 0C = 1
Adding two negatives 11 101011 0111ADD
11 0001V = 0C = 1
10 011010 0010ADD
00 1000V = 1C = 1
Z bit: Z = 1 if the result is all zeros. Z = 0 O/W
- Representation across levels:o When you write a program in C++ and run on a seven-bit computer,
The values of type int are stored in two’s complement representation.
o When you add two integers for example: i + j; where i = 8 and j = -2, the ISA level performs the operation
as follows:
o When you output like this: cout << “Tom”; it will be sent to the monitor as a sequences of 0’s and 1’s
101 0100110 1111110 1101
o Why must we deal with bits instead of English letters and decimal digits?
Because computers are electronic. The cheapest most reliable way to manufacture the electronic parts
that make up a computer is to make them binary.
9 of 33
01 011000 1100ADD
10 0010N = 1Z = 0V = 1C = 0
00 100011 1010ADD00 0010N = 0
Z = 0V = 0C = 1
00 110111 0011ADD
00 0000N = 0Z = 1V = 0C = 1
000 1000111 1110ADD00 0110N = 0
Z = 0V = 0C = 1
To interface the two different world human and machine there are coding system such as two’s complement representation and ASCII.
Examples of ASCII code
o Alternative representations: There are several ways to represent information.
The particular representation selected depends on how the data is to be processed.
Example: Positive integers are represented at level ISA by unsigned
binary representation. Positive integers can also be stored in binary coded decimal
(BCD) representation.o In BCD, each decimal digit requires exactly four
bits. o The decimal number 142 can be represented as:
0001 0100 0010 Unsigned binary is usually chosen when the data is
subjected more to arithmetic operations within the computer than to I/O.
BCD is frequently chosen when the data is financial in nature and is subjected to many I/O operations.
BCD is easier to convert to decimal for printed reports. The circuitry for BCD arithmetic operations is usually
slower than the circuitry for unsigned binary arithmetic operations.
10 of 33
Abstraction in Computer Systems:
As shown in the previous figure, computer systems can be split into seven levels of abstraction. Each level of abstraction has its own language:
• Level 7 (App7): Language dependent on application program.• Level 6 (HOL6): Machine-independent programming language.• Level 5 (Asmb5): Assembly Language.• Level 4 (OS4): Operating system calls.• Level 3 (ISA3): Machine Language.• Level 2 (Mc2): Microinstructions and register transfer.• Level 1 (LG1): Boolean algebra and truth tables.
Programs written in these languages instruct the computer to perform certain operations. A program to perform a specific task can be written at any of the levels. In early days, a human used to communicate with machines, which had only two levels: LG1 and ISA3, by programming them in machine language. Machine language is great and easily understood by machines but tedious and inconvenient for programmers. Therefore, Assembly language, at level Asmb5, was invented to help the human programmers.
Much time was wasted programming large computers, as only one programmers was able to work on them at a time, while other programmers were queued waiting for their turn. Gradually, operating systems at level OS4 were developed to so many users could access the computer simultaneously. Although assembly language helped programmers doing there job, programmers still had to learn a new language whenever a new computer was introduced by a company. All their old programs would not work on new the machines.
High-order languages at level HOL6 were then invented so programs could be transferred from one machine to another with little modification and because programming in high-order language is easier than programming at lower levels. There
11 of 33
are many HOL around us, among them: FORTRAN, C++, Java, and Lisp. The widespread availability of computer systems prompted the development of many applications programs at level App7. An application program is one written to solve a specific type of problem, such as printing payroll checks, typing documents, etc. This level of abstraction allows ordinary users to use computers as a tool without knowing the details at the lower levels.
Level G1, the lowest level, consists of electrical components, called logic gates. In the process of developing higher levels it was discovered that a level just above the logic gate could be useful in helping designers build the level ISA3 machine. Microprogramming at level Mc2 is used nowadays on some computer systems to implement the level ISA3 machine. Levels Mc2 was an important toll in the invention of hand-held calculators.
Computer systems components:
Computers were built to solve problems. Early computers were built to solve mathematical problems as they needed very powerful, efficient, fast, and accurate machines to perform the sophisticated tasks. Later on, computers have been used for solving a wide range of problems such as information processing for business applications. Computers also control machines such as: automobiles, robots and microwaves ovens. Regardless of the problem, computers solve any task by accepting inputs, processing them, and displaying results.
Computer systems consist of Software and Hardware. Hardware is the physical part of the system. Once the hardware designed it’s difficult and expensive to change. Software is a set of programs that instruct hardware. It’s easier to modify a software component. The same computer system can be used to solve different kinds of problems, by supplying different sets of instructions, software.
Operating systems:
o It’s the system program that makes the hardware usable.oExamples: Microsoft Windows. UNIX. Linux. Novell.oEach operating system has three functions:
File management. Memory management. Processor management.
oThe first most important thing you must learn is how to work with files (create, save, open, organize, delete, etc..).
oFiles are stored in the disk in scattered locations. To access a specific file the operating system maintains a directory that contains all the information about all stored files (name, memory location, size, etc.).
12 of 33
High-order level
C++ programming language
- It’s a high-order prog. lang.- Running a program in C++ is a three-step process:
1. Write the program in C++ using any text editor, save it with the extension .cpp. This program is called source code.
2. Translate/compile the code using a C++ compiler to the machine language. The generated code is called the object code.
3. Execute the object code.- C++ compiler.
o It’s a software that translates a program written in C++ to the machine code, allowing the machine to execute it.
o Once the source code is compiled into an object code you don’t need to recompile it every time you execute your code, unless modifications have been made to the source code.
The role of the C++ compiler
o The C++ compiler is like any other software, it has input, source program, does processing, and produces output, object code.
13 of 33
- Machine independence:
o Unlike ISA level languages, high-order languages are machine-independent.
A code written in C++ language can be ported to any other machine without having to rewrite/update the source code.
Once the source code has been compiled into an object code, the object code can only be ported to a machine of the exact same computing environment as the original one.
- Global variables vs. local variables:o Global variables:
Are not declared inside any function (including the main function). Are visible/accessible everywhere in the code and inside all
functions in the code. They are stored in the main memory.
o Local variables: Are declared inside functions. Can be accessed only where they are declared (i.e. within the scope
of the function). Are stored/allocated in the run-time stack.
14 of 33
The location of a local variable is released (i.e. made available to other usage) when the execution of its function has completed.
o Question: Why do we need local variables?
Functions in C++
- There are two kinds of functions in C++:o Functions that return voids. They are called procedures.o Functions that return some other data types. They are called functions
- Although in C++ lingo there is no procedures, but the term is used to differentiate between the types mentioned above. They are all called functions in C++ lingo.
- When your program calls a function/procedure, the compiler allocates storage on a stack.
- This stack is called run-time stack because the allocation takes place during program execution, as opposed to program translation.
- A stack is a container that stores values with the push operation and retrieve them with the pop operation. The policy of storage is Last In First Out (LIFO).
- Call-by-value parameters:o Formal parameters get the values of the actual parameters.o If the called function changed the value of its formal parameters, the
corresponding actual parameters in the calling function will not be affected.
o Changes are made only to the run-time stack.
o Procedures: In the run-time stack allocation takes place as following:
Push the actual parameters. Push the return address. Push storage for the local variables.
15 of 33
16 of 33
Before calling the printBar function
After calling the printBar function
The collection of all the items pushed into the run-time stack is called a stack frame or activation record.
After the completion of procedure execution items on the run-time stack are deallocated in reverse order:
Deallocate storage for the local variables. Pop the return address. Deallocate the actual paras.
o Functions: In the run-time stack allocation takes place as following:
Push storage for the returned value. Push the actual paras. Pus the return address. Push storage for the local variables.
17 of 33
-
Xz
18 of 33
19 of 33
- Computer Architectureo Architects design buildings from Walls, Doors, Ceilings.o Computers Architect design computers from input devices, output devices,
memories, CPU registers.o There are dozens of popular models that are available with different
architectures. We will explore a virtual computer (Pep/8) with fundamental
concepts that are applied to most computer systems.o Every computer hardware consists of the following:
Central Processing Unit Main Memory. Input Device, and Output Device.
Block diagram of the Pep/8 computer
o The central processing unit. It consists of the following registers: V & C bits indicate overflow and carry bits N & Z bits indicate the result is negative or zero. Accumulator contains results of operations. X, A, PC, SP help the CPU to access information in the main
memory. X register is for accessing elements of an array. PC is for accessing instructions SP is for accessing elements on the run-time stack. IR is for holding the instruction from memory.
20 of 33
o The main memory: Virtual Main memory contains 65,536 bytes locations.
Each byte has an address ranging from 0 to 65,535 Or in Hexa ranging from 0 to FFFF.
o
21 of 33
FFFFFFFE
Another style for depicting main memory. Better way to imagine main memory is to align them in one
column. You can tell from next address, how many bytes in
previous raw.
A word is two bytes in Pep/8. o The address of the word is the address
of the first byte: 000B written in Hexa to save space.
The content in binary
The content in hexadecimal
22 of 33
In machine language listing the address is followed by the content of the word.
The bit sequence is:o 0000 0010 1101 0001
In two’s complement the first bit is sign bit zero which is positive and the number is 721.
If the number is ASCII then it is equal to Q.
o I/O and Control: Input device for Pep/7
Text file and keyboard Output device for Pep/7:
Text file and Screen Data and Control:
Control signal all originate from CPU. The processor controls all other parts of the computer.
o Instruction format: Each computer has its own set of instructions wired into its CPU. The instruction set varies from manufacturer to another.
Often same company may produce a family of models that has set of instructions that is different from the set of another family.
Pep/8 has 39 instructions in its set. Each instruction consists of either a single byte called the
instruction specifier, or The instruction specifier followed immediately by a word
called the operand specifier. Instructions without an operand specifier are called unary.
Non-unary instruction
23 of 33
Unary instruction
The eight-bit instruction specifier can have several partso The first part is called the operation code, opcode.
May consist of as many as eight bits and as few as four.
o The remaining bits are subdivided into several fields depending on the instruction.
The figure below illustrates the component of an instruction:
The letter a stands for addressing mode.o There are eight addressing modes as shown below
24 of 33
0000 00000000 00000000 00010000 00010000 00100000 00100000 00110000 0011
0000 010a0000 010a0000 011a0000 011a0000 100a0000 100a0000 101a0000 101a0000 110a0000 110a0000 111a0000 111a0001 000a0001 000a0001 001a0001 001a0001 010a0001 010a0001 011a0001 011a
0001 100r0001 100r0001 101r0001 101r0001 110r0001 110r0001 111r0001 111r0010 000r0010 000r0010 001r0010 001r
Instruction SpecifierInstruction Specifier InstructionInstruction
25 of 33
Example: Determine the opcode, register, and addressing mode of the
1100 1011 instruction. Solution:
Starting from left the opcode is 1100. The next bit after the opcode is the r bit, which is 1
o Indicating the index register. The three bits after the r bit are the aaa bits, which are 011,
o Indicating stack-relative addressing. Therefore, the instruction loads a value from memory into
the index register using stack-relative addressing. The operand specifier for a non-unary instruction indicates the
operand to be processed by the instruction. The CPU can interpret the instruction specifier in several
different ways.o An ASCII character.o An integer in two’s complement representation.o An address in main memory.
Instructions are stored in the main memory. The address of the instruction in the main memory is the
address of the first byte of the instruction.
o Direct addressing: The addressing field determines how the CPU interprets the
operand specifier. An addressing-aaa of 001 indicates direct addressing.
With direct addressing the CPU interprets the operand specifier as the address in the main memory of the cell that contains the operand,
Oprnd = Mem[OprndSpec]o Selected Pep/8 instructions:
The Stop Instruction: When this instruction is executed, it simply makes the
computer stop. It’s a unary operation.
o It has no operand specifier. It has the instruction specifier 0000 0000.
The Load Instruction: It has the instruction specifier 1100 raaa. It loads one word (two bytes) from a memory location into
either the accumulator or the index register.o Depending on the value of r.
It affects the values of N and Z bits.o If the operand is negative, N is set to 1; O/W it is
cleared to 0.
26 of 33
o If the operand consists of 16 0’s, Z is set to 1; O/W it is cleared to 0.
Example:o Suppose the instruction to be executed is C1004A
in hexadecimal. It will look as followed in binary.
27 of 33
1 1 0 0 0 0 0 1 1 1 0 0 0 0 0 1 1 1 0 0 0 0 0 1C 1 0 0 4 A
Instruction specifier Operand specifierOpcode r aaa
The register-r field is 0, o Indicates a load to the accumulator.
The addressing-aaa is 001,o Indicates direct addressing.
The figure below shows the effects of the instruction on the CPU and main memory.
Before execution After execution The Store Instruction:
It has the instruction specifier 1110 raaa. It stores one word (two bytes) from either the accumulator
or the index register into a memory location. With direct addressing, the operands specifies the memory
location in which the information is stored. Example:
o Suppose the instruction to be executed is E9004A in hexadecimal. It will look as followed in binary.
The register-r field is 1, o The index register will be affected.
The addressing-aaa is 001,o Indicates direct addressing.
Before execution After execution
28 of 33
NZ
A 004A036D
92EF
CPU Mem
NZ
A 004A
10
92EF
92EF
CPU Mem
C1004ALoad accumulator
1 1 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 0E 9 0 0 4 A
Instruction specifier Operand specifierOpcode r aaa
X004A
16BCF082
CPU Mem
X004A
16BC 16BC
CPU Mem
E9004AStore index register
The Add Instruction: It has the instruction specifier 0111 raaa. It does the following:
1. Transfers one word (two bytes) from a memory location into either the accumulator or the index register.
o Depending on the value of r.2. It then adds the transferred data to the content of the
register.3. The result/sum is placed in the register and all the
status bits (N, Z, C, and V) are set accordingly. Example:
o Suppose the instruction to be executed is 79004A in hexadecimal. It will look as followed in binary.
The register-r field is 1, o The index register will be affected.
The addressing-aaa is 001,o Indicates direct addressing.
Before execution After execution
The And Instruction: It has the instruction specifier 1001 raaa. It does the following:
1. Transfers one word (two bytes) from a memory location into either the accumulator or the index register.o Depending on the value of r.
2. It then applies the AND operation on the transferred data and the content of the register.
29 of 33
0 1 1 1 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 07 9 0 0 4 A
Instruction specifier Operand specifierOpcode r aaa
NZVC
X 004A0005
FFF9
CPU Mem
004A
FFF9
CPU Mem
79004AAdd index register
NZVC
X
1000
FFFE
3. The result is placed in the register and the status bits N and Z are set accordingly.
Example:o Suppose the instruction to be executed is 99004A in
hexadecimal. It will look as followed in binary.
The register-r field is 1, o The index register will be affected.
The addressing-aaa is 001,o Indicates direct addressing.
Before execution After execution
The NOT Instruction: It has the instruction specifier 0001 100r. It a unary instruction.
o There is no operand specifier. It performs a NOT operation on the content of the register.
o Depending on the value of r. The result is placed in the register and the status bits N and
Z are set accordingly. Example:
o Suppose the instruction to be executed is 18 in hexadecimal. It will look as followed in binary.
30 of 33
1 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 09 9 0 0 4 A
Instruction specifier Operand specifierOpcode r aaa
NZ
X 004A5DC3
00FF
CPU Mem
004A
00FF
CPU Mem
99004AAnd index register
NZ
X
00
00C3
0 0 0 1 1 0 0 01 8
Instruction specifier Opcode r
The register-r field is 0, o The Accumulator register will be affected.
Before execution After execution
o Von Neumann Machines: In the earliest electronic computers, each program was hand-wired.
To change the program, the wires had to be manually reconnected.
It was a tedious and time-consuming process. Example: ENIAC.
o Its main memory was used only to store data. In 1945, von Neumann proposed a computer that can store
programs as well as data in the main memory. The first machine to use the concepts of von Neumann is
EDSAC at Cambridge University, UK in 1949. The von Neumann execution cycle:
The steps that are required to execute a program in the classical von Neumann machines are illustrated in the figure below.
The do loop is called the non Neumann execution cycle. The von Neumann cycle is wired into the CPU. The steps in the execution process are:
o Load the program: The program is loaded in the main memory
to be executed.o Initialize PC and SP:
31 of 33
NZ
X 0003
CPU
18Not accumulator
CPU
NZ
X
10
FFFC
The program counter is initialized to the address of the first instruction of the program in the main memory.
The PC always store the address of the instruction next in execution.
The stack pointer is initialized to an address in the main memory that is determined by the operating system.
The SP will hold the address of the top of the run-time stack.
o Fetch: Examines the 16 bits in the PC and
interprets them into an address in the memory.
It goes to that address in the memory and fetches the instruction specifier (one byte).
The eight bits will be held in the first byte of the instruction register IR.
o Decode instruction specifier: The CPU extracts the opcode from the
instruction specifier To determine which instruction to
execute. Depending on the opcode the CPU
extracts the register specifier and the addressing mode.
If the instruction is non-unary the CPU fetches the operand specifier from the memory, and stores it in the last two bytes in the IR.
o Increment PC The CPU adds 1 to the PC if the instruction
is unary. O/W it adds 3 to the PC.
After the addition, the new address in the PC will be the address of the next instruction in the memory.
o Execute the instruction fetched: The CPU will execute the instruction
fetched. The opcode will tell the CPU what
instruction to execute.o Repeat the cycle:
The CPU returns to the fetch operation unless the instruction just executed was the stop instruction 0000 0000.
32 of 33
o An example of a program written in machine language to output “Hi”.
33 of 33
Recommended