Overview - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

Overview

Description:

M[PC - 5] R2. M[x30F4] x3102. R2 R1 14 = x3102. R1 PC ... R4 M[R1] R3 R3 R4. R1 R1 1. R2 R2-1. NO. YES. Sample Program. R2 0. 0 1 0 1 0 1 0 0 1 0 1 0 0 0 0 0 ... – PowerPoint PPT presentation

Number of Views:21
Avg rating:3.0/5.0
Slides: 12
Provided by: larry109
Category:
Tags: overview

less

Transcript and Presenter's Notes

Title: Overview


1
Overview
The Operate Instructions - ADD, AND,
NOT The Data Movement Instructions - Load,
Load Address, Store Example Using Operate Data
Movement The Control instructions - BR,
JMP, TRAP
2
Example
Address Instruction Comments
x30F6 1 1 1 0 0 0 1 1 1 1 1 1 1 1 0 1 R1 ? PC 3 x30F4
x30F7 0 0 0 1 0 1 0 0 0 1 1 0 1 1 1 0 R2 ? R1 14 x3102
x30F8 0 0 1 1 0 1 0 1 1 1 1 1 1 0 1 1 MPC - 5 ? R2Mx30F4 ? x3102
x30F9 0 1 0 1 0 1 0 0 1 0 1 0 0 0 0 0 R2 ? 0
x30FA 0 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 R2 ? R2 5 5
x30FB 0 1 1 1 0 1 0 0 0 1 0 0 1 1 1 0 MR114 ? R2Mx3102 ? 5
x30FC 1 0 1 0 0 1 1 1 1 1 1 1 0 1 1 1 R3 ? MMx30F4 R3 ? Mx3102 R3 ? 5
Opcode
3
Branch Instruction
  • BR 0000 nzp PCoffset9
  • Branch specifies one or more condition codes
  • If the set bit is specified, the branch is taken
  • PC is set to the address specified in the
    instruction
  • Target address is made by adding SEXT(IR80) to
    the PC
  • If the branch is not taken - the next
    sequential instruction (PC) is executed.

4
BR
/////////////
/////

SEXT
5
Jump Instruction
  • JMP BaseR 1100 000 BaseR 000000
  • Jump is an unconditional branch -- always taken.
  • Base
  • Address is contents of the register
  • Allows any target address.

6
TRAP
  • Calls a service routine, identified by 8-bit
    trap vector.
  • When routine is done, PC is set to the
    instruction following TRAP.

vector routine
x23 input a character from the keyboard
x21 output a character to the monitor
x25 halt the program
7
LC-3 Memory Map
8
TRAPS
9
Using Branch Instructions
  • Compute sum of 12 integers.Numbers start at
    location x3100. Program starts at location x3000.

R1 ? x3100R3 ? 0R2 ? 12
R20?
R4 ? MR1R3 ? R3R4R1 ? R11 R2 ? R2-1
NO
YES
10
Sample Program
Address Instruction Comments
x3000 1 1 1 0 0 0 1 0 1 1 1 1 1 1 1 1 R1 ? x3100 (PC0xFF)
x3001 0 1 0 1 0 1 1 0 1 1 1 0 0 0 0 0 R3 ? 0
x3002 0 1 0 1 0 1 0 0 1 0 1 0 0 0 0 0 R2 ? 0
x3003 0 0 0 1 0 1 0 0 1 0 1 0 1 1 0 0 R2 ? 12
x3004 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 If Z, goto x300A (PC5)
x3005 0 1 1 0 1 0 0 0 0 1 0 0 0 0 0 0 Load next value to R4
x3006 0 0 0 1 0 1 1 0 1 1 0 0 0 0 0 1 Add to R3
x3007 0 0 0 1 0 0 1 0 0 1 1 0 0 0 0 1 Increment R1 (pointer)
X3008 0 0 0 1 0 1 0 0 1 0 1 1 1 1 1 1 Decrement R2 (counter)
x3009 0 0 0 0 1 1 1 1 1 1 1 1 1 0 1 0 Goto x3004 (PC-6)
11
Example 1 Multiply
  • This program multiplies two unsigned integers in
    R4 and R5.

x3200 0101010010100000 x3201 0001010010000100 x320
2 0001101101111111 x3203 0000011111111101 x3204
1111000000100101
R2 lt- 0 R2 lt- R2 R4 R5 lt- R5 1 BRzp
x3201 HALT
Write a Comment
User Comments (0)
About PowerShow.com