Chapter 3 Csa Summary
Chapter 3 Csa Summary
Machine Instructions
Characteristics - (Machine instructions/Computer instructions) the operation of the processor is determined by the instructions it executes. - (Instruction set) the collection of different instructions that the processor can execute. - Each instruction must contain the information required by the processor for execution.
Element - Operation code (opcode): specifies the operation to be performed using binary code. - Source operand reference: the operation may involve one or more source operands which is inputs for the operation. - Result operand reference: Produce a result. - Next instruction reference: Tells the processor where to fetch the next instruction.
Source and result operands can be in four areas: 1. Main or virtual memory: must be supplied. 2. I/O device: The instruction must specify the I/O module and device for the operation. If memory-mapped I/O is used, this is just another main or virtual memory address 3. Processor register: - contains one or more registers that may be referenced by machine instructions. - If more than one register exists each register is assigned a unique name Or number and the instruction must contain the number of the desired register. 4. Immediate: the value of the operand is contained in a field in the instruction being executed.
Instruction
Representation - Within the computer each instruction is represented by a sequence of bits. - The instruction is divided into fields, corresponding to the constituent elements of the instruction. - With most instruction sets, more than one format is used. - During instruction execution, an instruction is read into an instruction register (IR) in the processor. - The processor must be able to extract the data from the various instruction fields to perform the required operation. - It is difficult for us to deal with binary representations of machine instructions, therefore symbolic representation of machine instructions is used. e.g. ADD, SUB, LOAD, DIV, MUL - Opcodes are represented by abbreviations, called mnemonics that indicate the operation: Examples: ADD Add, SUB Subtract - Operands can also be represented in this way ADD A,B
Types -Data processing: Arithmetic and logic instructions. -Data storage (main memory): Memory instructions. -Data movement (I/O): I/O instructions. - Program flow control: Test and branch instructions.
Set Design - Very complex because it affects so many aspects of the computer system. - Defines many of the functions performed by the processor. - Programmers means of controlling the processor.
Operation repertoire How many and which operations to provide and how complex operations should be
Data types The various types of data upon which operations are performed
Instruction format Instruction length in bits, number of addresses, size of various fields, etc.
Registers Number of processor registers that can be referenced by instructions and their use
Addresses
Types of operand
Characters ASCII
Y = (A-B) / (C+D*E)
Addresses
0 addresses
1 addresses
2 addresses
3 addresses
Direct
Effective address (EA) = address field (A)
Indirect
EA = (A)
Pointer to operand
Register
EA = R
Register indirect
EA = (R)
Displacement (indexed)
EA = A + (R)
Addressing
Relative Addressing A version of displacement addressing R = Program counter, PC EA = A + (PC) i.e. get operand from A cells from current location pointed to by PC c.f locality of reference & cache usage Base-Register Addressing A holds displacement R holds pointer to base address R may be explicit or implicit e.g. segment registers in 80x86
Indexed Addressing A = base R = displacement EA = A + R Good for accessing arrays (iterative operations) - EA = A + R, -R++ (increment R after each operation) Stack Addressing Operand is (implicitly) on top of stack A stack is a reserved block of locations e.g. - ADD Pop top two items from stack and add
Instruction
Formats Define the layout of the bits of an instruction, in terms of its constituent fields Must include an opcode and, implicitly or explicitly, indicate the addressing mode for each operand For most instruction sets more than one instruction format is used
Length Most basic design issue Affected by and affects: Memory size Memory organization Bus structure CPU complexity CPU speed Should be equal to the memorytransfer length or one should be a multiple of the other Should be a multiple of the character length, which is usually 8 bits, and of the length of fixed-point numbers
o o o o o o
Allocation of bits
Number of addressing modes
Number of operands
Address range
Address granularity