Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8182131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:45:16+00:00 2026-06-07T00:45:16+00:00

I am developing a program that will bootstrap another program, so as a result

  • 0

I am developing a program that will bootstrap another program, so as a result I need to preserve the registers being passed to my program so that i can restore them before jumping to the program that should have loaded. It’s a bare metal system, no OS, no MMU (present, but unsed at the moment).

Here is my code, I would just like to know if it is correct or not since i don’t have an arm board to test on and i have to submit this soon,

also is it true that pc relative stores can use only source registers lower registers (r0-r7), i thought this was only thumb problem of not having access to high registers in certain instructions due to limited instruction width.

reset: @ entry point, mapped in reset vector

/* Store registers for bootstrapping */
STR     R0, [PC, #128]
STR     R1, [PC, #128]
STR     R2, [PC, #128]
STR     R3, [PC, #128]
STR     R4, [PC, #128]
STR     R5, [PC, #128]
STR     R6, [PC, #128]
STR     R7, [PC, #128]

/* Following registers can't be used in pc relative load/store */
MOV     R0, R8
STR     R0, [PC, #128]
MOV     R0, R9
STR     R0, [PC, #128]
MOV     R0, R10
STR     R0, [PC, #128]
MOV     R0, R11
STR     R0, [PC, #128]
MOV     R0, R12
STR     R0, [PC, #128]
MOV     R0, SP
STR     R0, [PC, #128]
MOV     R0, LR
STR     R0, [PC, #128]
MRS     R0, CPSR
STR     R0, [PC, #128]
MRS     R0, SPSR
STR     R0, [PC, #128]
ISB     SY
B       clear_regs

saved_regs:
.rept 32
    .word 0x00000000
.endr

.align
clear_regs:
MOV     R0,  #0
MOV     R1,  #0
MOV     R2,  #0
MOV     R3,  #0
MOV     R4,  #0
MOV     R5,  #0
MOV     R6,  #0
MOV     R7,  #0
MOV     R8,  #0
MOV     R9,  #0
MOV     R10, #0
MOV     R11, #0
MOV     R12, #0
MOV     SP,  #0
MOV     LR,  #0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T00:45:18+00:00Added an answer on June 7, 2026 at 12:45 am

    In ARM mode (vs Thumb mode) it’s fine to use the high registers in a PC relative store. Your assembler will warn you if something like that is not allowed. You might also want to consider using the STM (Store Multiple) instruction which allows you to specify a list of registers rather than doing them individually.

    You should probably let the assembler do the ‘hard’ work of calculating the PC offsets by using symbols instead of specifying the offsets by hand.

    reset: @ entry point, mapped in reset vector
    
    /* Store registers for bootstrapping */
    STR     R0, saved_regs
    ADR     R0, saved_regs + 4
    
    STMIA r0!, {r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15}
    
    MRS     R1, CPSR
    MRS     R2, SPSR
    STMIA   R0, {r1, r2}
    ISB     SY
    B       clear_regs
    
    saved_regs:
    .rept 32
    .word 0x00000000
    .endr
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing a PyQt program that will soon switch from an xml type backend
I'm currently developing a program that will generate reports based upon lead data. My
I am developing a C# program that will load files and get information such
I am developing a program that will be run through Windows remote desktop, and
I'm developing a program using App Inventor that will tweet stuff. I've assigned a
I'm developing an iPad app that will be distributed in-house using the Enterprise Program
I am developing a program in Java that I will use for registering data.
I'm developing a very simple program in VB2010 Express that will create folders based
I am developing a program that has to be very very fast. I will
I am developing a GUI program to use in a client/server system that will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.