Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emit thumb: Add support for MRS instruction #1637

Closed
wants to merge 1 commit into from

Conversation

HenrikSolver
Copy link
Contributor

This change makes it possible to use the MRS instruction in asm_thumb code.

@dpgeorge
Copy link
Member

I think "MRS" should be lower case to match all the other opcodes. And perhaps the special reg names as well...

What is the reason you need access to these registers?

@HenrikSolver
Copy link
Contributor Author

Regarding case:
I were thinking that way as well, but in the end I just followed the convention in the documentation from ARM.

The reason is some experimentation described here http://forum.micropython.org/viewtopic.php?f=3&t=1164 . Then there have been some discussions about using the PRIMASK register (in #1555), which require the MSR instruction. Since I have done part of that job already I wanted to share it.

@dpgeorge
Copy link
Member

dpgeorge commented Dec 4, 2015

I agree that loading special registers is useful in the context of inline assembler (and already we have vmrs to load floating point special regs). But this patch here costs 300 bytes and likely only a few special regs are really needed. So I suggest just supporting IPSR and PRIMASK to begin with, and implementing it the same way as vmrs.

mrs should be lower case, but the special reg names can stay upper case (that's how vmrs does it).

@dpgeorge
Copy link
Member

dpgeorge commented Dec 4, 2015

Actually, I think we want BASEPRI, not PRIMASK. PRIMASK can be changed using cpsie/cpsid. From the docs about BASEPRI: "[if non zero] the processor does not process any exception with a priority value greater than or equal to BASEPRI".

And maybe we should make the special regs lower case, since normal regs are also lower case, and then it's least surprise for the user (just tell them everything is lower case).

@HenrikSolver
Copy link
Contributor Author

I do not fully agree with you about mrs in lower case, but I will not argue about it if you want it this way :-). I have removed support for all registers exept IPSR and BASEPRI, updated the tests and rebased to latest master.

const char *reg_str = get_arg_str(pn);
for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(special_reg_name_table); i++) {
const special_reg_name_t *r = &special_reg_name_table[i];
if (strncmp(r->name, reg_str, MAX_SPECIAL_REG_NAME_LENGTH) == 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will catch extra stuff, eg, reg_str = "BASEPRIXXX" will be matched.

@HenrikSolver HenrikSolver force-pushed the Thumb_MRS branch 2 times, most recently from 94a3cdd to 8fcb357 Compare December 8, 2015 21:50
@HenrikSolver
Copy link
Contributor Author

I have now fixed the issues.

@dpgeorge
Copy link
Member

Merged in e242b17, thank you!

@dpgeorge dpgeorge closed this Dec 10, 2015
@HenrikSolver HenrikSolver deleted the Thumb_MRS branch December 10, 2015 19:07
tannewt pushed a commit to tannewt/circuitpython that referenced this pull request Mar 12, 2019
Update board info build to handle top level list.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants