Question
Convert logical labels into actual addresses. This process requires two passes over the instruction array. - Pass one: find the mapping of labels to the
Convert logical labels into actual addresses. This process requires two passes over the instruction array.
- Pass one: find the mapping of labels to the PC where that label occurs
- Pass two: for each instruction with a non-zero branch_label (jumps and branches) calculate the appropriate address using the mapping.
EXAMPLE:
Return a list of copies of the Instructions with the immediate field of the instruction filled in with the address calculated from the branch_label. The instruction should not be changed if it is not a branch instruction.
public static List resolve_addresses(List unresolved, int first_pc) {
return null;
}
before phase2: branch target for branch instructions indicated using branch_label field Address 0x00400000 0x00400004 0x00400008 0x0040000C 0x00400010 Label label1 Instruction addu Sto,$t0,$t1 abel"label1" ori to,t0,0xFF beqSt0,$12,label1 label-"label2", branch-label="label1" addiu $t1,t1,-1 addiu St2,$t2,-1 abe"label3" Important instruction field values label2 label3 after phase2: branch target for branch instructions indicated using immediate field Address 0x00400000 0x00400004 0x00400008 0x0040000C 0x00400010 Label Important instruction field values label1 label2 label3 Instruction addu St0,$t0,$t1 ori tO,$t0,0xFF beq to,$t2,-3 addiu St1,$t1,-1 addiu t2,t2,-1 immediate 3Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started