Computer Science 210 Computer Organization Machine Language Instructions: Data Movement
Data Movement Move data from memory to a register (load - LD, LDR, LDI, LEA) Move data from a register to memory (store - ST, STR, STI) 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Opcode Src or Address info Dst
PC-Relative Mode To compute the memory address: Sign-extend the address info (9-bit twos comp) Add the result to the incremented PC 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Opcode Src or Address info Dst
PC-Relative: LD and ST RDst M[PC + offset] M[PC + offset] RSrc 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0 0 1 0 0 1 0 1 1 0 1 0 1 1 1 1 RDst M[PC + offset] LD R2 x1AF 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0 0 1 1 0 1 0 1 1 0 1 0 1 1 1 1 M[PC + offset] RSrc ST R2 x1AF The operation is executed after the PC has been incremented Address must be within +256 or -255 of the LD or ST instruction
Data Path for LD
Data Path for ST
PC-Indirect Mode To compute the memory address: Sign-extend the address info (9-bit twos comp) Add the result to the incremented PC Use this address to locate another address in memory 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Opcode Src or Address info Dst
PC-Indirect: LDI and STI 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 0 1 0 0 1 1 1 1 1 0 0 1 1 0 0 RDst M[M[PC + offset]] LDI R3 x1CC 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 0 1 1 0 1 1 1 1 1 0 0 1 1 0 0 M[M[PC + offset]] RSrc STI R3 x1CC Contents at the address is another address, which can be anywhere in memory
Data Path for LDI
Base + Offset Mode To compute the memory address: Sign-extend the offset info (6-bit twos comp) Add the result to contents of the base register 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Opcode Src or Base Offset Dst
Base + Offset: LDR and STR 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0 1 1 0 0 0 1 0 1 0 0 1 1 1 0 1 RDst M[base + offset] LDR R1 R2 x1D 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0 1 1 1 0 0 1 0 1 0 1 0 1 1 1 1 M[base + offset] RSrc STR R1 R2 x1D Address does not depend on the PC Offset must range from -32 to +31
Data Path for LDR
Load Effective Address (LEA) Computes the address like PC-relative and just stores the result in the destination register Memory is not accessed 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 Opcode Src or Address info Dst
Data Path for LEA
For Friday Control Instructions