Bonus Questions

TypeQuiz 3 Material

Example: what are the values in registers R0-R4 after the following code executes?

PC + PCOffset = Label Address

Explanation

Going line by line:

AddressPCLabelInstruction/Value
x3000x3001LEA R0, A
x3001x3002LD R1, A
x3002x3003LDI R2, A
x3003x3004LDR R3, R0, 1
x3004x3005LDR R4, R1, -1
x3005x3006HALT
x3006x3007A .fill x4002  = x4002
x3007x3008B .fill x4001 = x4001
x3008x3009
…..
x4000x40011
x4001x40022
x4002x40033

Laying out Address spaces:

And the initialization of labels will take up subsequent memory spaces as well so:

A .fill x4002 @ NOT x4002 but x3006

B .fill x4001 @ NOT x4001 but x3007

This block of code is marked by .end (which again does not take memory space)

.orig x4000 starts new block of code at x4000

.fill 1 @x4000

.fill 2 @x4001

.fill 3 @x4002

.end

Back to the actual assembly instructions: