140 likes | 241 Views
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).
E N D
Computer Science 210Computer 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 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 RDst M[PC + offset] 0 0 1 0 0 1 0 1 1 0 1 0 1 1 1 1 LD R2 x1AF 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 M[PC + offset] RSrc 0 0 1 1 0 1 0 1 1 0 1 0 1 1 1 1 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
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 RDst M[M[PC + offset]] 1 0 1 0 0 1 1 1 1 1 0 0 1 1 0 0 LDI R3 x1CC 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 M[M[PC + offset]] RSrc 1 0 1 1 0 1 1 1 1 1 0 0 1 1 0 0 STI R3 x1CC Contents at the address is another address, which can be anywhere in memory
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 RDst M[base + offset] 0 1 1 0 0 0 1 0 1 0 0 1 1 1 0 1 LDR R1 R2 x1D 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 M[base + offset] RSrc 0 1 1 1 0 0 1 0 1 0 1 0 1 1 1 1 STR R1 R2 x1D Address does not depend on the PC Offset must range from -32 to +31
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