Computer Science 210 Computer Organization Machine Language Instructions

  • Slides: 15
Download presentation
Computer Science 210 Computer Organization Machine Language Instructions: Data Movement

Computer Science 210 Computer Organization Machine Language Instructions: Data Movement

Data Movement • Move data from memory to a register (load LD, LDR, LDI,

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 Opcode Src or Dst 9 8 7 6 5 4 3 Address info 2 1 0

PC-Relative Mode • To compute the memory address: – Sign-extend the address info (9

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 Opcode Src or Dst 9 8 7 6 5 4 3 Address info 2 1 0

PC-Relative: LD and ST 15 14 13 12 11 10 9 8 7 6

PC-Relative: LD and ST 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0 0 1 1 0 1 0 0 LD 1 R 2 x 1 AF 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0 0 1 1 0 1 ST 1 0 1 R 2 RDst M[PC + offset] RSrc x 1 AF 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 LD

Data Path for ST

Data Path for ST

PC-Indirect Mode • To compute the memory address: – Sign-extend the address info (9

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 Opcode Src or Dst 9 8 7 6 5 4 3 Address info 2 1 0

PC-Indirect: LDI and STI 15 14 13 12 11 10 9 8 7 6

PC-Indirect: LDI and STI 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 1 1 0 0 0 1 0 0 LDI 1 R 3 x 1 CC 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 1 1 1 0 0 0 1 STI 1 0 1 R 3 RDst M[M[PC + offset]] RSrc x 1 CC Contents at the address is another address, which can be anywhere in memory

Data Path for LDI

Data Path for LDI

Base + Offset Mode • To compute the memory address: – Sign-extend the offset

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 Opcode Src or Dst 9 8 7 Base 6 5 4 3 2 Offset 1 0

Base + Offset: LDR and STR 15 14 13 12 11 10 9 8

Base + Offset: LDR and STR 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0 1 1 1 0 0 LDR 0 R 1 R 2 x 1 D 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 0 1 0 1 1 1 1 STR 1 0 0 R 1 R 2 RDst M[base + offset] x 1 D Address does not depend on the PC Offset must range from -32 to +31 M[base + offset] RSrc

Data Path for LDR

Data Path for LDR

Load Effective Address (LEA) • Computes the address like PC-relative and just stores the

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 Opcode Src or Dst 9 8 7 6 5 4 3 Address info 2 1 0

Data Path for LEA

Data Path for LEA

For Friday Control Instructions

For Friday Control Instructions