Docsity

LC-3: Instruction Set - Lecture Slides | BME 303, Study notes of Biology

Partial preview of the text

Download LC-3: Instruction Set - Lecture Slides | BME 303 and more Study notes Biology in PDF only on Docsity!

BME303 Intro. to Computing

LC-3: Instruction SetLC 3: Instruction Set

•^

Opcodes (total of 15) 1.^

Operate

instructions: ADD, AND, NOT

Data movement

instructions: LD, LDI, LDR, LEA, ST,

STR STISTR, STI

Control

instructions: BR, JSR/JSRR, JMP, RTI, TRAP

Opcode

Operand(s)

BME303 Intro. to Computing

What is Data Movement?What is Data Movement?

0000

0000 0000 0000 0000

Registers

Memory

R^
R^
R^
R^

x

0000 0000 0000 0000 x

1101 1111 0001 1101 x

1111 1111 1111 1111 x

0010 0010 1101 0000 0004

1101 1111 1101 1111

R^
R^
R^
R^

x

1101 1111 1101 1111 x

0001 0001 0000 0000 x

1000 1111 1101 1111

…

…

R^

…

xFFF

0000 0000 0000 0000 xFFFA

1101 1111 0001 1101 xFFFB

1111 1111 1111 1111 … xFFFB

1111 1111 1111 1111 xFFFC

0010 0010 1101 0000 xFFFD

1011 0101 1101 0101 xFFFE

0000 0000 0000 0000 xFFFF

1000 1111 1101 1111 xFFFF

1000 1111 1101 1111

Input/Output (Ch9)

BME303 Intro. to Computing

How do we move data?How do we move data?

0000

0000 0000 0000 0000

Registers

Memory

R^
R^
R^
R^

x

0000 0000 0000 0000 x

1101 1111 0001 1101 x

1111 1111 1111 1111 x

0010 0010 1101 0000 0004

1101 1111 1101 1111

A^

R^
R^
R^
R^

x

1101 1111 1101 1111 x

0001 0001 0000 0000 x

1000 1111 1101 1111

…

…

A

R^

Opcode

Operand(s)

opcode

DR or SR

Address bits

Dilemma: How to express a 16-bit address with only 9 bits?

BME303 Intro. to Computing

Addressing Modes

dd ess

g

odes

•^

4 addressing modes for data movement:1.^

Direct

Indirect

Base+Offset

In memory

Base Offset

Immediate

(explicitly in the instruction itself)

BME303 Intro. to Computing

Memory Addressing ModesMemory Addressing ModesPC+

Memory

Direct

data

IR

IR[8:0]

address

data

BME303 Intro. to Computing

Direct (PC-Relative): LDDirect (PC Relative): LD

BME303 Intro. to Computing

Example: LDExample: LD

Example (instruction 0010101011111101 at address 0x4000):

(1a)

PC = 0x4000 PC

+^

= 0x

(1a)

PC = 0x4000, PC

= 0x

(1b)

PCoffset9 = IR<8:0> = 0 1111 1101

sign extension (SEXT) of IR<8:0>: SEXT(PCoffeset9) = 0x00FD

PC

+^

+ SEXT(PCoffset9) = 0x40FE

Æ

MAR

MDR=mem[MAR]

DR = R

Å

MDR = mem[PC

+^

+ SEXT(PCoffset9)] = mem[0x40FE]

BME303 Intro. to Computing

Memory Addressing ModesMemory Addressing ModesPC+

Memory

Direct

data

IR

IR[8:0]

address

data

PC+

Memory

Indirect

address

IR

IR[8:0]

address

data

BME303 Intro. to Computing

Indirect: LDIIndirect: LDI

BME303 Intro. to Computing

Indirect: LDIIndirect: LDI

BME303 Intro. to Computing

Data Movement Instructions

a a

o e

e

s

uc o s

-^

Load

read data from memory to register

-^

Load – read data from memory to register–

LD: direct mode– LDI: indirect mode– LDR: base+offset mode

-^

Store -- write data from register to memory–

ST: direct modeSTI: indirect mode

In memory

-^

STI: indirect mode

-^

STR: base+offset mode

-^

Load effective address -- compute address, save in register

p^

,^

g

-^

LEA: immediate mode

-^

does not access memory

BME303 Intro. to Computing

Memory Addressing ModesMemory Addressing ModesPC+

Memory

Direct

data

IR

IR[8:0]

address

data

PC+

Memory

Indirect

address

IR

IR[8:0]

address

data

GPR

Memory

Base+Offset

data

Base

IR

IR[5:0]

address

BME303 Intro. to Computing

Base+Offset: LDRBase+Offset: LDR

BME303 Intro. to Computing

Base+Offset: STRBase+Offset: STR