CPSC 2310 - DAY 7 AUGUST 31, 2016 ================================================================================ One goal of instruction set design is to minimize instruction length Many instructions were designed with compilers in mind. Instruction Length .Affected by: .Memory size .Memory organization .Bus structure .CPU complexity .CPU speed Trade offs: Large instruction sets vs. small programs Small instruction sets vs. large programs Large memory vs. longer instructions Allocation of bits Determines several important factors .Register versus memory .Tradeoff between # Registers and program size .Studies suggest optimal number between 8 and 32 .Most new architectures have 32 or more .x86 architecture allows some computation in memory .Address range .large address space requires large instructions for direct addressing .many architectures have some restricted or short forms of displacment addressing .ex PowerPC 16-bit displacement addressing .Address granularity .Size of object addressed .Typicallly 8, 16, 32 or 64 Commmon addressing modes * .Immediate * .Direct * .Indirect .Register .Register indirect .Displacement .Implied (stack) Know that Accumulator machine has one main register Know that the stack based machine doesn't have registers, operands come from stack Load/Store architecture - only load or store are allowed to access memory Know Immediate, Direct, and Indirect addressing Immediate Addressing .the instruction itself contains the value to be used, located in the address field of the instruction .the value is stored in memory immediately after the instruction opcode .similar to using a constant in HLL Instruction +---+------------+ | | operand | +---+------------+ Direct Addressing .The instruction tells where the value can be found, but the value itself is out in memory. .The address field contains the address of the operand Effective address(EA) = address field (A) .In a HLL, direct addressing is used for global variables Instruction +----------------+ | | A | +----------------+ - Memory | +-----------------+ | | | | | | | | | | | | | +-----------------+ ---| operand | +-----------------+ Indirect Addressing .The address is a pointer which holds another address Register Addressing ------------------- .There is a very limited number of addresses .A very small address field is needed .Shorter instructions .No memory access needed to fetch EA .Very fast execution Register-Indirect Addressing .Similar to memory-indirect Indexed Addressing ------------------ A = Base R = displacement EA = A + R Good for accessing arrays EA = A + R R++ The ARM architecture provides preindexed and postindexed addressing Good for iterating through arrays