Presentation is loading. Please wait.

Presentation is loading. Please wait.

Overview The Operate Instructions - ADD, AND, NOT The Data Movement Instructions - Load, Load Address, Store Example Using Operate & Data Movement The.

Similar presentations


Presentation on theme: "Overview The Operate Instructions - ADD, AND, NOT The Data Movement Instructions - Load, Load Address, Store Example Using Operate & Data Movement The."— Presentation transcript:

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 AddressInstructionComments x30F61 1 1 0 0 0 1 1 1 1 1 1 1 1 0 1 R1  PC – 3 = x30F4 x30F70 0 0 1 0 1 0 0 0 1 1 0 1 1 1 0 R2  R1 + 14 = x3102 x30F80 0 1 1 0 1 0 1 1 1 1 1 1 0 1 1 M[PC - 5]  R2 M[x30F4]  x3102 x30F90 1 0 1 0 1 0 0 1 0 1 0 0 0 0 0 R2  0 x30FA0 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 R2  R2 + 5 = 5 x30FB0 1 1 1 0 1 0 0 0 1 0 0 1 1 1 0 M[R1+14]  R2 M[x3102]  5 x30FC1 0 1 0 0 1 1 1 1 1 1 1 0 1 1 1 R3  M[M[x30F4]] R3  M[x3102] 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(IR[8:0]) 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. vectorroutine x23input a character from the keyboard x21output a character to the monitor x25halt 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  x3100 R3  0 R2  12 R2=0? R4  M[R1] R3  R3+R4 R1  R1+1 R2  R2-1 NO YES

10 Sample Program AddressInstructionComments x30001 1 1 0 0 0 1 0 1 1 1 1 1 1 1 1 R1  x3100 (PC+0xFF) x30010 1 0 1 0 1 1 0 1 1 1 0 0 0 0 0 R3  0 x30020 1 0 1 0 1 0 0 1 0 1 0 0 0 0 0 R2  0 x30030 0 0 1 0 1 0 0 1 0 1 0 1 1 0 0 R2  12 x30040 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1If Z, goto x300A (PC+5) x30050 1 1 0 1 0 0 0 0 1 0 0 0 0 0 0Load next value to R4 x30060 0 0 1 0 1 1 0 1 1 0 0 0 0 0 1Add to R3 x30070 0 0 1 0 0 1 0 0 1 1 0 0 0 0 1Increment R1 (pointer) X30080 0 0 1 0 1 0 0 1 0 1 1 1 1 1 1Decrement R2 (counter) x30090 0 0 0 1 1 1 1 1 1 1 1 1 0 1 0Goto x3004 (PC-6)

11 Example 1: Multiply This program multiplies two unsigned integers in R4 and R5. x3200 0101010010100000 x3201 0001010010000100 x3202 0001101101111111 x3203 0000011111111101 x3204 1111000000100101 clear R2 add R4 to R2 decrement R5 R5 = 0? HALT No Yes R2 <- 0 R2 <- R2 + R4 R5 <- R5 – 1 BRzp x3201 HALT


Download ppt "Overview The Operate Instructions - ADD, AND, NOT The Data Movement Instructions - Load, Load Address, Store Example Using Operate & Data Movement The."

Similar presentations


Ads by Google