Download presentation

Presentation is loading. Please wait.

Published bySarahi Tankard Modified about 1 year ago

1
The LC-3 – Chapter 6 COMP 2620 Dr. James Money COMP

2
Example 1: Multiplying In this example, we consider a program that should multiply two numbers that are non- negative This is needed since the LC-3 does not have a multiply instruction The numbers are in R4 and R5 and the result should be stored in R2

3
Example 1: Multiplying x x x x x clear R2 add R4 to R2 decrement R5 R5 = 0? HALT No Yes Set R4 = 10, R5 =3. Run program. Result: R2 = 40, not 30.

4
PCR2R4R5 x x x x x x x x x x x x x x PC and registers at the beginning of each instruction PCR2R4R5 x x x x Single-stepping Breakpoint at branch (x3203) Executing loop one time too many. Branch at x3203 should be based on Z bit only, not Z and P. Should stop looping here!

5
Example 2: Summing In this example, we want to sum an array of numbers The numbers start at location 0x3100 There are 10 numbers The result should be in R1 when the module finishes

6
Example 2: Summing R4 = 0? HALT No Yes R1 = 0 R4 = 10 R2 = x3100 R1 = R1 + M[R2] R2 = R2 + 1 R4 = R4 - 1 x x x x x x x x x x

7
Example 2: Summing Running the data below yields R1 = x0024, but the sum should be x8135. What happened? AddressContents x3100x3107 x3101x2819 x3102x0110 x3103x0310 x3104x0110 x3105x1110 x3106x11B1 x3107x0019 x3108x0007 x3109x0004 PCR1R2R4 x x x x x30040x Start single-stepping program... Should be x3100! Loading contents of M[x3100], not address. Change opcode of x3003 from 0010 (LD) to 1110 (LEA).

Similar presentations

© 2017 SlidePlayer.com Inc.

All rights reserved.

Ads by Google