Problem Description:
Create the conversion table of the MMU, when constructing each table item, the base address pointer plus the relative offset, translated into the Assembly, the offset is shifted to the right 2 bits, plus the base addresses.
Problem Analysis:
The high 12 bits of the vaddr are the offsets of the segment address relative to the base address, and the MMU locates the offset address of the table entry based on the VADDR high 12-bit offset multiplied by 4 into the relative address. So the pointer translates to the assembly right shift 2 bits means multiply by 4, which calculates the offset address relative to the base address instead of the offset.
unsigned long *ttb;unsigned long VADDR;TTB = TTB + (vaddr >>); LDR R3, [FP, #-12]lsr R3, R3, #20lsl R2 , R3, #2ldr R3, [FP, #-16]add R3, R3, R2STR R3, [FP, #-16]
[Question note] [pointer addition translated into assembly right shift 2 bits]