[Question note] [pointer addition translated into assembly right shift 2 bits]

Source: Internet
Author: User

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]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.