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 > B -- 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 "> B</ h2 > 4< p class ="aml "> Branch causes a branch to a target address.</ p > 5 6< p class ="desc "> 7 It has encodings from the following instruction sets: 8 A32 ( 9< a href ="#iclass_a1 "> A1</ a > 10 ) 11 and 12 T32 ( 13< a href ="#iclass_t1 "> T1</ a > 14 , 15< a href ="#iclass_t2 "> T2</ a > 16 , 17< a href ="#iclass_t3 "> T3</ a > 18 and 19< a href ="#iclass_t4 "> T4</ a > 20 ) 21 . 22</ p > 23< 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 "> 1</ td >< td > 0</ td >< td class ="r "> 1</ td >< td class ="lr "> 0</ td >< td colspan ="24 "class ="lr "> imm24</ td ></ tr >< tr class ="secondrow ">< td colspan ="4 "class ="droppedname "> cond</ td >< td colspan ="3 "/>< td />< td colspan ="24 "/></ tr ></ tbody ></ table ></ div >< div class ="encoding ">< h4 class ="encoding "> A1</ h4 >< a id ="B_A1 "/>< p class ="asm-code "> B{< a href ="#sa_c_1 "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_label_4 "title ="The label of instruction that is to be branched to "> <label></ a ></ p ></ div >< p class ="pseudocode "> constant imm32 =< a href ="shared_pseudocode.html#impl-shared.SignExtend.2 "title ="function: bits(N) SignExtend(bits(M) x, integer N) "> SignExtend</ a > (imm24:'00', 32);</ p > 24< h3 class ="classheading ">< a id ="iclass_t1 "/> T1</ h3 >< div class ="regdiagram-16 ">< 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 ></ tr ></ thead >< tbody >< tr class ="firstrow ">< td class ="l "> 1</ td >< td > 1</ td >< td > 0</ td >< td class ="r "> 1</ td >< td colspan ="4 "class ="lr "> != 111x</ td >< td colspan ="8 "class ="lr "> imm8</ td ></ tr >< tr class ="secondrow ">< td colspan ="4 "/>< td colspan ="4 "class ="droppedname "> cond</ td >< td colspan ="8 "/></ tr ></ tbody ></ table ></ div >< div class ="encoding ">< h4 class ="encoding "> T1</ h4 >< a id ="B_T1 "/>< p class ="asm-code "> B< 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_label "title ="The label of instruction that is to be branched to "> <label></ a > 25 // 26 27 (Not permitted in IT block) 28</ p ></ div >< p class ="pseudocode "> if cond == '1110' then SEE "UDF"; 29if cond == '1111' then SEE "SVC"; 30constant imm32 =< a href ="shared_pseudocode.html#impl-shared.SignExtend.2 "title ="function: bits(N) SignExtend(bits(M) x, integer N) "> SignExtend</ a > (imm8:'0', 32); 31if< a href ="shared_pseudocode.html#impl-aarch32.InITBlock.0 "title ="function: boolean InITBlock() "> InITBlock</ a > () then UNPREDICTABLE;</ p > 32< h3 class ="classheading ">< a id ="iclass_t2 "/> T2</ h3 >< div class ="regdiagram-16 ">< 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 ></ tr ></ thead >< tbody >< tr class ="firstrow ">< td class ="l "> 1</ td >< td > 1</ td >< td > 1</ td >< td > 0</ td >< td class ="r "> 0</ td >< td colspan ="11 "class ="lr "> imm11</ td ></ tr ></ tbody ></ table ></ div >< div class ="encoding ">< h4 class ="encoding "> T2</ h4 >< a id ="B_T2 "/>< p class ="asm-code "> B{< a href ="#sa_c_1 "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_label_1 "title ="The label of instruction that is to be branched to "> <label></ a > 33 // 34 35 (Outside or last in IT block) 36</ p ></ div >< p class ="pseudocode "> constant imm32 =< a href ="shared_pseudocode.html#impl-shared.SignExtend.2 "title ="function: bits(N) SignExtend(bits(M) x, integer N) "> SignExtend</ a > (imm11:'0', 32); 37if< a href ="shared_pseudocode.html#impl-aarch32.InITBlock.0 "title ="function: boolean InITBlock() "> InITBlock</ a > () && !< a href ="shared_pseudocode.html#impl-aarch32.LastInITBlock.0 "title ="function: boolean LastInITBlock() "> LastInITBlock</ a > () then UNPREDICTABLE;</ p > 38< h3 class ="classheading ">< a id ="iclass_t3 "/> T3</ 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 class ="r "> 0</ td >< td class ="lr "> S</ td >< td colspan ="4 "class ="lr "> != 111x</ td >< td colspan ="6 "class ="lr "> imm6</ td >< td class ="l "> 1</ td >< td class ="r "> 0</ td >< td class ="lr "> J1</ td >< td class ="lr "> 0</ td >< td class ="lr "> J2</ td >< td colspan ="11 "class ="lr "> imm11</ td ></ tr >< tr class ="secondrow ">< td colspan ="5 "/>< td />< td colspan ="4 "class ="droppedname "> cond</ td >< td colspan ="6 "/>< td colspan ="2 "/>< td />< td />< td />< td colspan ="11 "/></ tr ></ tbody ></ table ></ div >< div class ="encoding ">< h4 class ="encoding "> T3</ h4 >< a id ="B_T3 "/>< p class ="asm-code "> B< a href ="#sa_c_2 "title ="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}} "> <c></ a > .W< a href ="#sa_label_2 "title ="The label of instruction that is to be branched to "> <label></ a > 39 // 40 41 (Not permitted in IT block, and <label> can be represented in T1) 42</ p >< p class ="asm-code "> B< a href ="#sa_c_2 "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_label_2 "title ="The label of instruction that is to be branched to "> <label></ a > 43 // 44 45 (Not permitted in IT block) 46</ p ></ div >< p class ="pseudocode "> if cond<3:1> == '111' then SEE "Related encodings"; 47constant imm32 =< a href ="shared_pseudocode.html#impl-shared.SignExtend.2 "title ="function: bits(N) SignExtend(bits(M) x, integer N) "> SignExtend</ a > (S:J2:J1:imm6:imm11:'0', 32); 48if< a href ="shared_pseudocode.html#impl-aarch32.InITBlock.0 "title ="function: boolean InITBlock() "> InITBlock</ a > () then UNPREDICTABLE;</ p > 49< h3 class ="classheading ">< a id ="iclass_t4 "/> T4</ 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 class ="r "> 0</ td >< td class ="lr "> S</ td >< td colspan ="10 "class ="lr "> imm10</ td >< td class ="l "> 1</ td >< td class ="r "> 0</ td >< td class ="lr "> J1</ td >< td class ="lr "> 1</ td >< td class ="lr "> J2</ td >< td colspan ="11 "class ="lr "> imm11</ td ></ tr ></ tbody ></ table ></ div >< div class ="encoding ">< h4 class ="encoding "> T4</ h4 >< a id ="B_T4 "/>< p class ="asm-code "> B{< a href ="#sa_c_1 "title ="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}} "> <c></ a > }.W< a href ="#sa_label_3 "title ="The label of instruction that is to be branched to "> <label></ a > 50 // 51 52 (<label> can be represented in T2) 53</ p >< p class ="asm-code "> B{< a href ="#sa_c_1 "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_label_3 "title ="The label of instruction that is to be branched to "> <label></ a ></ p ></ div >< p class ="pseudocode "> constant I1 = NOT(J1 EOR S); constant I2 = NOT(J2 EOR S); 54constant imm32 =< a href ="shared_pseudocode.html#impl-shared.SignExtend.2 "title ="function: bits(N) SignExtend(bits(M) x, integer N) "> SignExtend</ a > (S:I1:I2:imm10:imm11:'0', 32); 55if< a href ="shared_pseudocode.html#impl-aarch32.InITBlock.0 "title ="function: boolean InITBlock() "> InITBlock</ a > () && !< a href ="shared_pseudocode.html#impl-aarch32.LastInITBlock.0 "title ="function: boolean LastInITBlock() "> LastInITBlock</ a > () then UNPREDICTABLE;</ p > 56< div class ="encoding-notes "> 57< p class ="aml "> For more information about the< span class ="arm-defined-word "> constrained unpredictable</ span > behavior, see< a class ="armarm-xref "title ="Reference to Armv8 ARM section "data-linkend ="CJAEGDJC "> Architectural Constraints on UNPREDICTABLE behaviors</ a > .</ p > 58< p class ="aml "> Related encodings:< a class ="armarm-xref "title ="Reference to Armv8 ARM section "data-linkend ="T32.encoding_index.bcrtrl "> Branches and miscellaneous control</ a > .</ p > 59</ 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_1 "/> 60 61< p class ="aml "> For encoding A1, T2 and T4: see< a class ="armarm-xref "title ="Reference to Armv8 ARM section "data-linkend ="Babbefhf "> Standard assembler syntax fields</ a > .</ p > 62 63</ td ></ tr >< tr >< td />< td >< a id ="sa_c "/> 64 65 66 67 68 69< p class ="aml "> For encoding T1: see< a class ="armarm-xref "title ="Reference to Armv8 ARM section "data-linkend ="Babbefhf "> Standard assembler syntax fields</ a > . Must not be AL or omitted.</ p > 70 71</ td ></ tr >< tr >< td />< td >< a id ="sa_c_2 "/> 72 73 74 75 76 77< p class ="aml "> For encoding T3: see< a class ="armarm-xref "title ="Reference to Armv8 ARM section "data-linkend ="Babbefhf "> Standard assembler syntax fields</ a > . <c> must not be AL or omitted.</ p > 78 79</ td ></ tr ></ table >< table >< col class ="asyn-l "/>< col class ="asyn-r "/>< tr >< td > <q></ td >< td >< a id ="sa_q "/> 80 81< p class ="aml "> See< a class ="armarm-xref "title ="Reference to Armv8 ARM section "data-linkend ="Babbefhf "> Standard assembler syntax fields</ a > .</ p > 82 83</ td ></ tr ></ table >< table >< col class ="asyn-l "/>< col class ="asyn-r "/>< tr >< td > <label></ td >< td >< a id ="sa_label_4 "/> 84 85 86 87 88 89< p class ="aml "> For encoding A1: the label of the instruction that is to be branched to. The assembler calculates the required value of the offset from the PC value of the< span class ="asm-code "> B</ span > instruction to this label, then selects an encoding that sets imm32 to that offset.</ p > 90< p class ="aml "> Permitted offsets are multiples of 4 in the range –33554432 to 33554428.</ p > 91 92</ td ></ tr >< tr >< td />< td >< a id ="sa_label "/> 93 94 95 96 97 98< p class ="aml "> For encoding T1: the label of the instruction that is to be branched to. The assembler calculates the required value of the offset from the PC value of the< span class ="asm-code "> B</ span > instruction to this label, then selects an encoding that sets imm32 to that offset. Permitted offsets are even numbers in the range –256 to 254.</ p > 99 100</ td ></ tr >< tr >< td />< td >< a id ="sa_label_1 "/> 101 102 103 104 105 106< p class ="aml "> For encoding T2: the label of the instruction that is to be branched to. The assembler calculates the required value of the offset from the PC value of the< span class ="asm-code "> B</ span > instruction to this label, then selects an encoding that sets imm32 to that offset. Permitted offsets are even numbers in the range –2048 to 2046.</ p > 107 108</ td ></ tr >< tr >< td />< td >< a id ="sa_label_2 "/> 109 110 111 112 113 114< p class ="aml "> For encoding T3: the label of the instruction that is to be branched to. The assembler calculates the required value of the offset from the PC value of the< span class ="asm-code "> B</ span > instruction to this label, then selects an encoding that sets imm32 to that offset.</ p > 115< p class ="aml "> Permitted offsets are even numbers in the range –1048576 to 1048574.</ p > 116 117</ td ></ tr >< tr >< td />< td >< a id ="sa_label_3 "/> 118 119 120 121 122 123< p class ="aml "> For encoding T4: the label of the instruction that is to be branched to. The assembler calculates the required value of the offset from the PC value of the< span class ="asm-code "> B</ span > instruction to this label, then selects an encoding that sets imm32 to that offset.</ p > 124< p class ="aml "> Permitted offsets are even numbers in the range –16777216 to 16777214.</ p > 125 126</ td ></ tr ></ table ></ div >< div class ="syntax-notes "/> 127< div class ="ps ">< a id ="execute "/>< h3 class ="pseudocode "> Operation</ h3 > 128< p class ="pseudocode "> if< a href ="shared_pseudocode.html#impl-aarch32.ConditionPassed.0 "title ="function: boolean ConditionPassed() "> ConditionPassed</ a > () then 129 EncodingSpecificOperations(); 130< a href ="shared_pseudocode.html#impl-aarch32.BranchWritePC.2 "title ="function: BranchWritePC(bits(32) address_in, BranchType branch_type) "> BranchWritePC</ a > (< a href ="shared_pseudocode.html#impl-aarch32.PC32.read.none "title ="accessor: bits(32) PC32 "> PC32</ a > + imm32,< a href ="shared_pseudocode.html#BranchType_DIR "title ="enumeration BranchType { BranchType_DIRCALL, BranchType_INDCALL, BranchType_ERET, BranchType_DBGEXIT, BranchType_RET, BranchType_DIR, BranchType_INDIR, BranchType_EXCEPTION, BranchType_TMFAIL, BranchType_RESET, BranchType_UNKNOWN} "> BranchType_DIR</ a > );</ p > 131</ div > 132< 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 "> 133 Internal version only: isa v01_31, pseudocode v2024-09_rel 134 ; Build timestamp: 2024-09-26T13:26 135</ p >< p class ="copyconf "> 136 Copyright © 2010-2024 Arm Limited or its affiliates. All rights reserved. 137 This document is Non-Confidential. 138</ p ></ body ></ html >