collab/polyglot-riscv-arm
what if the same machine code was valid riscv and arm asm
git clone https://git.julia.blue/collab/polyglot-riscv-arm
885cc4e
main
1< ?xml version="1.0" encoding="utf-8"?> 2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" > 3< html xmlns ="http://www.w3.org/1999/xhtml ">< head >< link rel ="stylesheet "type ="text/css "href ="insn.css "/>< meta name ="generator "content ="iform.xsl "/>< title > MRS -- AArch32</ title ></ head >< body >< table style ="margin: 0 auto; ">< tr >< td >< div class ="topbar ">< a href ="index.html "> Base Instructions</ a ></ div ></ td >< td >< div class ="topbar ">< a href ="fpsimdindex.html "> SIMD&FP Instructions</ a ></ div ></ td >< td >< div class ="topbar ">< a href ="a32_encindex.html "> A32 Instructions by Encoding</ a ></ div ></ td >< td >< div class ="topbar ">< a href ="t32_encindex.html "> T32 Instructions by Encoding</ a ></ div ></ td >< td >< div class ="topbar ">< a href ="shared_pseudocode.html "> Shared Pseudocode</ a ></ div ></ td >< td >< div class ="topbar ">< a href ="notice.html "> Proprietary Notice</ a ></ div ></ td ></ tr ></ table >< hr />< h2 class ="instruction-section "> MRS</ h2 > 4< p class ="aml "> Move Special register to general-purpose register moves the value of the< a class ="armarm-xref "title ="Reference to Armv8 ARM section "data-linkend ="CJAGBHBH "> APSR</ a > ,< a class ="armarm-xref "title ="Reference to Armv8 ARM section "data-linkend ="CIHJBHJA "> CPSR</ a > , or< a class ="armarm-xref "title ="Reference to Armv8 ARM section "data-linkend ="CHDDAABB "> SPSR</ a > _<current_mode> into a general-purpose register.</ p > 5< p class ="aml "> Arm recommends the APSR form when only the N, Z, C, V, Q, and GE[3:0] bits are being written. For more information, see< a class ="armarm-xref "title ="Reference to Armv8 ARM section "data-linkend ="CJAGBHBH "> APSR</ a > .</ p > 6< p class ="aml "> An< span class ="asm-code "> MRS</ span > that accesses the< a class ="armarm-xref "title ="Reference to Armv8 ARM section "data-linkend ="CHDDAABB "> SPSRs</ a > is< span class ="arm-defined-word "> unpredictable</ span > if executed in User mode or System mode.</ p > 7< p class ="aml "> An< span class ="asm-code "> MRS</ span > that is executed in User mode and accesses the< a class ="armarm-xref "title ="Reference to Armv8 ARM section "data-linkend ="CIHJBHJA "> CPSR</ a > returns an< span class ="arm-defined-word "> unknown</ span > value for the< a class ="armarm-xref "title ="Reference to Armv8 ARM section "data-linkend ="CIHJBHJA "> CPSR</ a > .{E, A, I, F, M} fields.</ p > 8 9< p class ="desc "> 10 It has encodings from the following instruction sets: 11 A32 ( 12< a href ="#iclass_a1 "> A1</ a > 13 ) 14 and 15 T32 ( 16< a href ="#iclass_t1 "> T1</ a > 17 ) 18 . 19</ p > 20< h3 class ="classheading ">< a id ="iclass_a1 "/> A1</ h3 >< div class ="regdiagram-32 ">< table class ="regdiagram ">< thead >< tr >< td > 31</ td >< td > 30</ td >< td > 29</ td >< td > 28</ td >< td > 27</ td >< td > 26</ td >< td > 25</ td >< td > 24</ td >< td > 23</ td >< td > 22</ td >< td > 21</ td >< td > 20</ td >< td > 19</ td >< td > 18</ td >< td > 17</ td >< td > 16</ td >< td > 15</ td >< td > 14</ td >< td > 13</ td >< td > 12</ td >< td > 11</ td >< td > 10</ td >< td > 9</ td >< td > 8</ td >< td > 7</ td >< td > 6</ td >< td > 5</ td >< td > 4</ td >< td > 3</ td >< td > 2</ td >< td > 1</ td >< td > 0</ td ></ tr ></ thead >< tbody >< tr class ="firstrow ">< td colspan ="4 "class ="lr "> != 1111</ td >< td class ="l "> 0</ td >< td > 0</ td >< td > 0</ td >< td > 1</ td >< td class ="r "> 0</ td >< td class ="lr "> R</ td >< td class ="lr "> 0</ td >< td class ="lr "> 0</ td >< td class ="l "> (1)</ td >< td > (1)</ td >< td > (1)</ td >< td class ="r "> (1)</ td >< td colspan ="4 "class ="lr "> Rd</ td >< td class ="lr "> (0)</ td >< td class ="lr "> (0)</ td >< td class ="lr "> 0</ td >< td class ="lr "> (0)</ td >< td class ="l "> 0</ td >< td > 0</ td >< td > 0</ td >< td class ="r "> 0</ td >< td class ="l "> (0)</ td >< td > (0)</ td >< td > (0)</ td >< td class ="r "> (0)</ td ></ tr >< tr class ="secondrow ">< td colspan ="4 "class ="droppedname "> cond</ td >< td colspan ="5 "/>< td />< td />< td />< td colspan ="4 "/>< td colspan ="4 "/>< td />< td />< td />< td />< td colspan ="4 "/>< td colspan ="4 "/></ tr ></ tbody ></ table ></ div >< div class ="encoding ">< h4 class ="encoding "> A1</ h4 >< a id ="MRS_A1_AS "/>< p class ="asm-code "> MRS{< a href ="#sa_c "title ="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}} "> <c></ a > }{< a href ="#sa_q "title ="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}} "> <q></ a > }< a href ="#sa_rd "title ="General-purpose destination register (field "Rd") "> <Rd></ a > ,< a href ="#sa_spec_reg "title ="Special register to be accessed (field "R") [APSR,CPSR,SPSR] "> <spec_reg></ a ></ p ></ div >< p class ="pseudocode "> constant d =< a href ="shared_pseudocode.html#impl-shared.UInt.1 "title ="function: integer UInt(bits(N) x) "> UInt</ a > (Rd); constant read_spsr = (R == '1'); 21if d == 15 then UNPREDICTABLE;</ p > 22< h3 class ="classheading ">< a id ="iclass_t1 "/> T1</ h3 >< div class ="regdiagram-16x2 ">< table class ="regdiagram ">< thead >< tr >< td > 15</ td >< td > 14</ td >< td > 13</ td >< td > 12</ td >< td > 11</ td >< td > 10</ td >< td > 9</ td >< td > 8</ td >< td > 7</ td >< td > 6</ td >< td > 5</ td >< td > 4</ td >< td > 3</ td >< td > 2</ td >< td > 1</ td >< td > 0</ td >< td > 15</ td >< td > 14</ td >< td > 13</ td >< td > 12</ td >< td > 11</ td >< td > 10</ td >< td > 9</ td >< td > 8</ td >< td > 7</ td >< td > 6</ td >< td > 5</ td >< td > 4</ td >< td > 3</ td >< td > 2</ td >< td > 1</ td >< td > 0</ td ></ tr ></ thead >< tbody >< tr class ="firstrow ">< td class ="l "> 1</ td >< td > 1</ td >< td > 1</ td >< td > 1</ td >< td > 0</ td >< td > 0</ td >< td > 1</ td >< td > 1</ td >< td > 1</ td >< td > 1</ td >< td class ="r "> 1</ td >< td class ="lr "> R</ td >< td class ="lr "> (1)</ td >< td class ="lr "> (1)</ td >< td class ="lr "> (1)</ td >< td class ="lr "> (1)</ td >< td class ="l "> 1</ td >< td class ="r "> 0</ td >< td class ="lr "> (0)</ td >< td class ="lr "> 0</ td >< td colspan ="4 "class ="lr "> Rd</ td >< td class ="lr "> (0)</ td >< td class ="lr "> (0)</ td >< td class ="lr "> 0</ td >< td class ="lr "> (0)</ td >< td class ="lr "> (0)</ td >< td class ="lr "> (0)</ td >< td class ="lr "> (0)</ td >< td class ="lr "> (0)</ td ></ tr ></ tbody ></ table ></ div >< div class ="encoding ">< h4 class ="encoding "> T1</ h4 >< a id ="MRS_T1_AS "/>< p class ="asm-code "> MRS{< a href ="#sa_c "title ="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}} "> <c></ a > }{< a href ="#sa_q "title ="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}} "> <q></ a > }< a href ="#sa_rd "title ="General-purpose destination register (field "Rd") "> <Rd></ a > ,< a href ="#sa_spec_reg "title ="Special register to be accessed (field "R") [APSR,CPSR,SPSR] "> <spec_reg></ a ></ p ></ div >< p class ="pseudocode "> constant d =< a href ="shared_pseudocode.html#impl-shared.UInt.1 "title ="function: integer UInt(bits(N) x) "> UInt</ a > (Rd); constant read_spsr = (R == '1'); 23// Armv8-A removes UNPREDICTABLE for R13 24if d == 15 then UNPREDICTABLE;</ p > 25< div class ="encoding-notes "> 26< p class ="aml "> For more information about the< span class ="arm-defined-word "> constrained unpredictable</ span > behavior of this instruction, see< a class ="armarm-xref "title ="Reference to Armv8 ARM section "data-linkend ="CJAEGDJC "> Architectural Constraints on UNPREDICTABLE behaviors</ a > .</ p > 27</ div >< h3 class ="explanations "> Assembler Symbols</ h3 >< div class ="explanations ">< table >< col class ="asyn-l "/>< col class ="asyn-r "/>< tr >< td > <c></ td >< td >< a id ="sa_c "/> 28 29< p class ="aml "> See< a class ="armarm-xref "title ="Reference to Armv8 ARM section "data-linkend ="Babbefhf "> Standard assembler syntax fields</ a > .</ p > 30 31</ td ></ tr ></ table >< table >< col class ="asyn-l "/>< col class ="asyn-r "/>< tr >< td > <q></ td >< td >< a id ="sa_q "/> 32 33< p class ="aml "> See< a class ="armarm-xref "title ="Reference to Armv8 ARM section "data-linkend ="Babbefhf "> Standard assembler syntax fields</ a > .</ p > 34 35</ td ></ tr ></ table >< table >< col class ="asyn-l "/>< col class ="asyn-r "/>< tr >< td > <Rd></ td >< td >< a id ="sa_rd "/> 36 37< p class ="aml "> Is the general-purpose destination register, encoded in the "Rd" field.</ p > 38 39</ td ></ tr ></ table >< table >< col class ="asyn-l "/>< col class ="asyn-r "/>< tr >< td > <spec_reg></ td >< td >< a id ="sa_spec_reg "/> 40< p > Is the special register to be accessed, 41 encoded in 42< q > R</ q > : 43</ p > 44< table class ="valuetable "> 45 46< thead > 47< tr > 48< th class ="bitfield "> R</ th > 49< th class ="symbol "> <spec_reg></ th > 50</ tr > 51</ thead > 52< tbody > 53< tr > 54< td class ="bitfield "> 0</ td > 55< td class ="symbol "> CPSR|APSR</ td > 56</ tr > 57< tr > 58< td class ="bitfield "> 1</ td > 59< td class ="symbol "> SPSR</ td > 60</ tr > 61</ tbody > 62 63</ table > 64</ td ></ tr ></ table ></ div >< div class ="syntax-notes "/> 65< div class ="ps ">< a id ="execute "/>< h3 class ="pseudocode "> Operation</ h3 > 66< p class ="pseudocode "> if< a href ="shared_pseudocode.html#impl-aarch32.ConditionPassed.0 "title ="function: boolean ConditionPassed() "> ConditionPassed</ a > () then 67 EncodingSpecificOperations(); 68 if read_spsr then 69 if PSTATE.M IN {< a href ="shared_pseudocode.html#M32_User "title ="constant bits(5) M32_User = '10000' "> M32_User</ a > ,< a href ="shared_pseudocode.html#M32_System "title ="constant bits(5) M32_System = '11111' "> M32_System</ a > } then 70 UNPREDICTABLE; 71 else 72< a href ="shared_pseudocode.html#impl-aarch32.R.write.1 "title ="accessor: R[integer n] = bits(32) value "> R</ a > [d] =< a href ="shared_pseudocode.html#impl-shared.SPSR_curr.read.0 "title ="accessor: bits(32) SPSR_curr[] "> SPSR_curr</ a > []; 73 else 74 // CPSR has same bit assignments as SPSR, but with the IT, J, SS, IL, and T bits masked out. 75 constant bits(32) mask = '11111000 11101111 00000011 11011111'; 76 psr_val =< a href ="shared_pseudocode.html#impl-shared.GetPSRFromPSTATE.2 "title ="function: bits(N) GetPSRFromPSTATE(ExceptionalOccurrenceTargetState targetELState, integer N) "> GetPSRFromPSTATE</ a > (< a href ="shared_pseudocode.html#AArch32_NonDebugState "title ="enumeration ExceptionalOccurrenceTargetState { AArch32_NonDebugState, AArch64_NonDebugState, DebugState } "> AArch32_NonDebugState</ a > , 32) AND mask; 77 if PSTATE.EL ==< a href ="shared_pseudocode.html#EL0 "title ="constant bits(2) EL0 = '00' "> EL0</ a > then 78 // If accessed from User mode return UNKNOWN values for E, A, I, F bits, bits<9:6>, 79 // and for the M field, bits<4:0> 80 psr_val<22> = bits(1) UNKNOWN; 81 psr_val<9:6> = bits(4) UNKNOWN; 82 psr_val<4:0> = bits(5) UNKNOWN; 83< a href ="shared_pseudocode.html#impl-aarch32.R.write.1 "title ="accessor: R[integer n] = bits(32) value "> R</ a > [d] = psr_val;</ p > 84</ div > 85< h3 > CONSTRAINED UNPREDICTABLE behavior</ h3 >< p > If< span class ="pseudocode "> PSTATE.M IN {M32_User, M32_System} && read_spsr</ span > , then one of the following behaviors must occur:</ p >< ul >< li > The instruction is< span class ="arm-defined-word "> undefined</ span > .</ li >< li > The instruction executes as< span class ="asm-code "> NOP</ span > .</ li ></ ul >< hr />< table style ="margin: 0 auto; ">< tr >< td >< div class ="topbar ">< a href ="index.html "> Base Instructions</ a ></ div ></ td >< td >< div class ="topbar ">< a href ="fpsimdindex.html "> SIMD&FP Instructions</ a ></ div ></ td >< td >< div class ="topbar ">< a href ="a32_encindex.html "> A32 Instructions by Encoding</ a ></ div ></ td >< td >< div class ="topbar ">< a href ="t32_encindex.html "> T32 Instructions by Encoding</ a ></ div ></ td >< td >< div class ="topbar ">< a href ="shared_pseudocode.html "> Shared Pseudocode</ a ></ div ></ td >< td >< div class ="topbar ">< a href ="notice.html "> Proprietary Notice</ a ></ div ></ td ></ tr ></ table >< p class ="versions "> 86 Internal version only: isa v01_31, pseudocode v2024-09_rel 87 ; Build timestamp: 2024-09-26T13:26 88</ p >< p class ="copyconf "> 89 Copyright © 2010-2024 Arm Limited or its affiliates. All rights reserved. 90 This document is Non-Confidential. 91</ p ></ body ></ html >