Unformatted text preview:

Memory AccessCOMP375 1Memory Access Memory Access ModesModesCOMP375 Computer Architecture dO i tiand OrganizationSteps in Address Mapping• Programmer selects a variable name.•Compiler allocates space and selects a•Compiler allocates space and selects a relative address.• Linker combines object files and updates references to relative address to be program addresses.pg• Operating system allocates memory for the program and copies it into RAM.Relocatable Address Adjustment0000 0Relocatable Object Files Executable01000500150100 1000 10150 1510 1520 152150 302Adjusting Addresses• When the linker combines object files to ttblitthhthcreate an executable, it goes through the program and adjusts every address.• When a program is executed, it is loaded into memory. The hardware adjusts each program relative address to a hardwareprogram relative address to a hardware address.Memory AccessCOMP375 2Program Memory Types• Global variables– Data segment• Local variables and parameters–Stack• Dynamic variables– Heap• Constants– Data segment or instruction segment• Instructions– Instruction segmentProgram Memory OrganizationProgram instructionsGlobal dataStackStackHeapIntel methodEffective Address• The effective address (or logical address or virtual address) is the program relative )pgaddress.• The hardware maps the effective address to the physical address.• Different programs in different physical dd h h ff iaddresses may have the same effective address.• Effective addresses can be the result of address calculations.Where is the data?• The operands for an instruction can be in RAM i t i th i t tiRAM, a register or in the instruction.• The instruction specifies where the operand is located.• There are several ways the operand’s address can be specifiedaddress can be specified.• Different addressing modes have been created for different program situations.Memory AccessCOMP375 3Addressing modes• immediateit•register• memory direct• register indirect• register indirect with offset•memory indirect•memory indirect• register + offset memory indirect• displacementImmediate• The data is part of the instruction.• Immediate data items are read-only.• There is usually a size limit.Instruction addressdata register datamemoryRegister• The data is in a CPU register.• The instruction might indicate which registerInstruction addressdata register datamemoryMemory Direct• The data is in memory.• The instruction contains the address of the memory location.Instruction addressdata register datamemoryMemory AccessCOMP375 4Register Indirect• The address of the data is in a CPU itregister.• Useful if the address is calculated.Instruction addressdata register datamemoryRegister Indirect with Offset• The address of the data is the sum of the i t ti ff t fi ld d i t linstruction offset field and a register value.• Useful when addressing an array.Instruction addressdata register datamemoryMemory Indirect• A memory location contains the address of th d tthe data.• Useful for pointers.Instruction addressdata register datamemoryRegister Offset & Memory Indirect• The sum of the instruction offset field and a register value gives the location of the address in memory.• Useful when addressing ref parameters.Instruction addressdata register datamemoryMemory AccessCOMP375 5Displacement• The address of the data is the sum of the instruction offset field and the programinstruction offset field and the program counter.• Used for short jumpsInstruction addressProgram Counter instructionmemoryStack Addressing• The same as Register Indirect with Offset using the stack pointer registerusing the stack pointer register• Useful when addressing local variables or parameters.Instruction addressstack pointer register datamemoryFunction Calls• To call a function or method, the program ti hd th tk dthcounter is pushed on the stack and then the program counter is loaded with the address of the function.• This puts the address of the instruction after the function call on the stack.after the function call on the stack.• To return the return address is popped from the stack and loaded into the program counter.What are the Instructions?Add Subtract Multiply Divide Load Store JumpEql Jump01234567OpcodesInstruction Formats11111111112222222222333opcode register index registermemory address34 4 21opcodeunusedreg 1 reg 2 reg 331444Load and StoreAdd, Sub, Mult and DivideInstruction Formats123456789012345678901234567890121010011010000000000000000000010100100010000101110100100000000001000011110010011010001010000000000000000000001001Memory AccessCOMP375 6Notes on the Example Architecture• This is an example of a “Load/Store” hit t O l th l d d tarchitecture. Only the load and store instructions access memory.• Why is there a one bit unused field in the arithmetic instructions?•Why is the opcode always the left most bits?•Why is the opcode always the left most bits?• The format of the jump instructions was not shown. What might be a good format?Instruction Cycle• Fetch the instruction from the memory dd i th P C t i taddress in the Program Counter register• Increment the Program Counter• Decode the type of instruction• Fetch the operands• Execute the instruction• Store the resultsBasic Processor Components• Program Counter – contains the address fth ti t ti t tof the next instruction to execute.• Arithmetic Logic Unit – logic to perform arithmetic and logical functions• User registers – hold dataMemory Address Registercontains the•Memory Address Register–contains the address to be copied to or from RAM• Memory Buffer Register – contains data copied to or from RAM.Instruction FetchMemory Address Reg Memory Buffer RegProgram Counter Instruction RegisterR1R2. . .R16ALUMemory ReadMemory AccessCOMP375 7Instruction FetchMemory Address Reg Memory Buffer RegProgram Counter Instruction RegisterR1R2. . .R16ALURead ResultIncrement Program CounterMemory Address Reg Memory Buffer RegProgram Counter Instruction RegisterR1R2. . .R16ALU+1Increment Program CounterMemory Address Reg Memory Buffer RegProgram Counter Instruction RegisterR1R2. . .R16ALUDecode InstructionMemory Address Reg Memory Buffer RegProgram Counter Instruction RegisterR1R2. . .R16ALUMemory AccessCOMP375 8Operand FetchMemory Address Reg Memory Buffer RegProgram Counter Instruction RegisterR1R2. . .R16ALUMemory


View Full Document

NCA&T COMP 375 - Memory Access Modes

Download Memory Access Modes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Memory Access Modes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Memory Access Modes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?