NAND2TET UNIT 4 HACK Flashcards
A device capable of performing a fixed set of elementary operations. These typically include arithmetic and logic operations, memory access operations, and control (also called branching) operations. The operands of these operations are binary values that come from registers and selected memory locations. Likewise, the results of the operations can be stored either in registers or in selected memory locations.
Processor -CPU
CPU?
Central Processing Unit
A device capable of performing a fixed set of elementary operations. These typically include arithmetic and logic operations, memory access operations, and control (also called branching) operations. The operands of these operations are binary values that come from registers and selected memory locations. Likewise, the results of the operations can be stored either in registers or in selected memory locations.
Registers?
Registers Memory access is a relatively slow operation, requiring long instruction formats (an address may require 32 bits). For this reason, most processors are equipped with several registers, each capable of holding a single value. Located in the processor’s immediate proximity, the registers serve as a high-speed local memory, allowing the processor to manipulate data and instructions quickly. This setting enables the programmer to minimize the use of memory access commands, thus speeding up the program’s execution
Machine language
A machine language can be viewed as an agreed-upon formalism, designed to manipulate a memory using a processor and a set of registers.
Memory
The term memory refers loosely to the collection of hardware devices that store data and instructions in a computer. From the programmer’s standpoint, all memories have the same structure: A continuous array of cells of some fixed width, also called words or locations, each having a unique address. Hence, an individual word (representing either a data item or an instruction) is specified by supplying its address. In what follows we will refer to such individual words using the equivalent notation Memory[address], RAM[address], or M[address] for brevity
LOAD R1, 67 // R1< –Memory[67]
Direct addressing
The most common way to address the memory is to express a specific address or use a symbol that refers to a specific address, as follows:
60 Chapter 4
LOAD R1,67 // R1< –Memory[67]
// Or, assuming that bar refers to memory address 67:
LOAD R1,bar // R1< –Memory[67]
Addressing modes are?
All computers feature explicit load and store commands, designed to move data between registers and memory. These memory access commands may use several types of addressing modes— ways of specifying the address of the required memory word. As usual, different computers offer different possibilities and different notations, but the following three memory access modes are almost always supported:
- Direct addressing
- Immediate addressing
- Indirect addressing
Memory access commands may use several types of addressing modes— ways of specifying the address of the required memory word. As usual, different computers offer different possibilities and different notations, but the following three memory access modes are almost always supported:
- Direct addressing
- Immediate addressing
- Indirect addressing
Indirect addressing
Indirect addressing In this addressing mode the address of the required memory location is not hard-coded into the instruction; instead, the instruction specifies a memory location that holds the required address. This addressing mode is used to handle pointers. For example, consider the high-level command x=foo[j], where foo is an array variable and x and j are integer variables. What is the machine language equivalent of this command? Well, when the array foo is declared and initialized in the high-level program, the compiler allocates a memory segment to hold the array data and makes the symbol foo refer to the base address of that segment. Now, when the compiler later encounters references to array cells like foo[j], it translates them as follows. First, note that the jth array entry should be physically located in a memory location that is at a displacement j from the array’s base address (assuming, for simplicity, that each array element uses a single word). Hence the address corresponding to the expression foo[j] can be easily calculated by adding the value of j to the value of foo. Thus in the C programming language, for example, a command like x=foo[j] can be also expressed as x=\*(foo+j), where the notation ‘‘\*n’’ stands for ‘‘the value of Memory[n]’’. When translated into machine language, such commands typically generate the following code (depending on the assembly language syntax): *// Translation of x=foo[j] or x=\*(foo+j):*
ADD R1, foo, j // R1< –foo+j
LOAD* R2, R1 // R2< –Memory[R1]
STR R2, x// x< –R2
Immediate addressing
This form of addressing is used to load constants— namely, load values that appear in the instruction code: Instead of treating the numeric field that appears in the instruction as an address, we simply load the value of the field itself into the register, as follows:
LOADI R1, 67 // R1< –67