Computer Engineering Concepts |
Since the computer operates on binary information, both the data and the instructions need to be provided in binary form for the computer to be able to perform a given task. To do this the information and the data must be available to the computer while the task is performed. In the early days of computing the data and instructions were stored in separate banks of memory. However, with the Von Neumann architecture both the data and instructions are held in the same memory, but distinguished by using different locations. In previous chapters we saw how different types of information could be represented in binary form. Now the question is how can instructions be represented in binary form? This is accomplished by representing the various operations the computer can perform with binary codes. These binary codes are commonly referred to as operation codes or opcodes for short. Each opcode for a processor will perform a given operation, and all the opcodes together form the instructions set of the processor, since each processor will have a finite set of opcodes. Different types of processors will have different instruction sets or opcodes; for example, the opcodes for an Intel processor will be different from the opcodes for a Motorola processor. That is why a program compiled on one processor will not work with another processor.
Processor manufacturers usually don’t change the opcode of a processor because of downward compatibility issues. For example, the Intel 80486 processor will have all the opcodes of the Intel 80386 processor, and more opcodes to handle the upgraded features of the 80486 processor. This approach allows programs that were developed for the 80386 processor to work on the 80486 processor without any changes. The program works on the newer processor because all the opcodes that are needed are identical in the newer processor. This provides the end user with cost savings, and it allows a manufacturer to maintain their market share.
A computer instruction begins with the operation code and specifies the memory address on which the operation is to be performed. The instruction could be represented as follows, where 4 bits of the instruction are used for the opcode and 8 bit are used for the address.
In this case the number of operations is limited to 24 or 16, because only four bits are present for the opcode. Similarly the addresses are limited to 28 or 256. The number of bits used for the instruction is dependent on the number of operations available within a processor and the capacity of the addressable memory. Different opcodes will perform different functions on the address. For example, opcode 0000 could be set to delete the information at the specified address.
Since the opcodes are essentially bit patterns, they are usually hard to remember. To make it easier for the programmer to work with these opcodes, a mnemonic is used. A mnemonic is a word or a phase that represents the function of the opcode, and is easy to remember. Imagine that a primitive computer with 23 (8) opcodes is being programmed. Assume the 8 opcodes represent the operations outlined in table 8.1.
If the job of the program is to get three numbers from memory and add the first two numbers and subtract the third, then it could be achieved by using the sequence of operation codes shown below. Assuming the instruction is 8 bits, with 3 for the opcode and 5 for the address, and the three numbers of the data are located at memory addresses 00001, 00010, and 00011, then the program in machine code would be as follows.
101 00100
The machine code instructions shown above will accomplish the calculation task. It is assumed that the information was already present in memory and the final result is stored in memory at the 00100 address. This program unfortunately is very hard to understand from a human perspective because at each step the bit pattern needs to be converted to a concept for understanding. Now imagine a program that performs a complex operation. In this case the number of lines will be far greater, and it becomes harder to follow the logic and process by looking at a sequence of bits. To solve this problem, mnemonics, words or symbols, are used to represent the function of each instruction instead of the binary opcode. The instruction set table shows a mnemonic for each instruction. The mnemonic set can be thought of as a symbolic language to program the machine. The advantage of symbolic representation of the opcodes are: faster program development, reduced number of errors during programing, faster error detection, and the ease with which an existing program can be modified. These advantages are significant enough for programmers to create instructions using symbols, and then translate it to machine code. The above example program represented using mnemonics or symbolic language would be as follows:
getA 1
getB 2
addAB 4
getA 3
cmpA
incA
getB 4
addAB 4
These instructions are definitely easier to understand from a human perspective, but it must be noted that a computer cannot understand instructions in this form. Therefore, the instructions are created in symbolic form and then converted to the binary form for the computer to perform the instructions. Even though this two-step process might seem inefficient it is in fact more efficient from a human point of view.
From the previous example we can see that multiple instructions are needed to perform a simple task. The set of instructions for a given simple task like adding of two numbers will always remain the same; in this case, the first 3 lines of instruction. Since such simple tasks are commonly repeated, it is a waste of a programmer’s time to repeat the work over and over again, so the simple task can be represented with a symbol or word. This is called a macro instruction. A macro instruction is a collection of simple instructions that performs a simple task. At this stage the programmer is twice removed from the actual operation of the machine. Macro instructions are task oriented, and therefore are close to human thinking, thus making it easier to work with. The disadvantage is the lack of direct and detailed control over the machine. The process of giving instructions to the computer using macro instruction is called high level programming.
Explore Further: Motorola 68000 Instruction Set The Motorola 68000 processor was introduced int the late 1970s and it was used in some of the popular PCs of the early 80s, including the Apple MacIntosh which is considered to be the first mass produced PC. Research the processor instruction set online considering the following: How many instructions are available? How many bits are used for the opcode and how many bits are used for the address? Are there opcodes for the M68000 that similar to the sample opcodes provided in Table 8.1? The processor is classified as a CISC type processor. What is meant by this? |
High level programming
As discussed earlier, high level programming is based on a task oriented approach to programming. This is close to the human concept of providing instructions using a language where each word means something and the collection of words form the instruction. High level languages are modeled on this idea where there are meanings to words, and rules for combining words. Due to the similarity between macro instructions and human language, macro instructions are thought of as a high level programming language. The words used to define a task in a high level programming language are called keywords, and the rules for using keywords is referred to as syntax. Different high level languages have different keywords and different syntax, but this should not be cause for concern because the concept behind all of them is essentially the same. Once the concepts of a high level language have been mastered, then moving from one language to another becomes a relatively simple task of determining the equivalent keywords and the syntax.
An advantage with high level programming languages is portability, which means a program written in a high level language could be made to work on any type of computer provided the necessary translations to machine code can be made. This is possible because high level languages are task oriented, and all general purpose computers are essentially capable of performing simple tasks like addition, input, output, storage, etc. So, to make the high level instructions portable from one machine to another what is needed is translating capability, a compiler or interpreter for that particular type of machine.
Within high level programming there are two categories; object oriented programming and structured programming, with structured programming being a subset of object oriented programming.
In high level programming there are a few basic concepts. These concepts will be discussed in detail with examples provided in different languages to emphasize the idea that all high level languages are conceptually the same. For detailed information on the language that you are using, consult a language reference manual.
Processor Design Philosophy
There are two approaches to processor design and handling of instructions within a processor. One approach is called Complex Instruction Set Computing (CISC), and the other approach is called Reduced Instruction Set Computing (RISC). In the CISC approach there are many instructions covering a variety of tasks, therefore increasing the instruction set and reducing the speed of the computer as more complex circuitry is required to implement the instructions. The advantage of the CISC approach is that most tasks can be easily programmed using simple instructions.
In the RISC approach a minimal number of instructions define the instruction set of the processor. Due to this minimalist approach the instructions are simple in nature, and therefore takes less time to process. This reduction in processing time of an instruction consequently leads to increased performance of the processor. The disadvantage of the RISC approach is that some common tasks might require several instructions to be executed before the task is accomplished.
In the RISC approach the hardware is simplified at the expense of software complexity, and in the CISC approach the software is simplified at the expense of hardware complexity. Presently there is a general trend towards the RISC approach to processor design. This trend is due to the fact that most software design is currently done using high level programming languages, and these compilers do not fully utilize the large set of instructions present in a CISC processor. Of the various instructions available in a CISC not all are used with the same frequency. Thus creating a trend towards the RISC philosophy.
Parallel Processing
As the information processing volume increases it generates a need faster processing systems. An increase in processing speed can be achieved in one of two ways. One approach is to use a single complex processor with more components or power packed in it, and the other approach is by using many simple processors to do a task. Most computers in use today fall into the single processor category. A computer that uses multiple processors is commonly referred to as parallel processing computer because it shares the processing load amongst its many processors.
In the single processor approach the programming aspect of the computer is relatively easy, but it makes the processor design more complex. On the other hand, in the parallel processing approach the programming becomes complex, and the processor design becomes simple. One of the big challenges of parallel processing is in breaking down a complex task into a set of simple tasks that can be handled by many processors. There are also other challenges, like the control and flow of data and instructions to the various processors and the return of the processed information. In trying to overcome some of the challenges different designers have come up with different solutions to solve some of these problems. Though currently the single processor design dominates the computer market of today, the multiprocessor design has the potential to become a significant force in the future.
8.2 Practice Questions 1. How is the instruction and the data distinguished in memory? 2. What are the two parts of an instruction? 3. Syntax is very important in high level programing. What is syntax and why is it important? 4. What is meant by the term mnemonic and how is it used? 5. How many instructions can a computer have with a 5 bit opcode? 6. A computer has an 8 bit instruction with 5 address bits. What is the maximum number of opcodes it can have? 7. Explain the thinking behind the CISC approach to processor design? 8. Pipelining is a concept that is commonly used in RISC processor design. Research pipelining and explain the concept of pipelining. 9. What are some of the challenges in parallel processing? |