I am new to ARM Cortex and facing difficulty to understand how TBB branches.
Code snippet attached –
TBB [PC,R1] BrTable1 DCB ((P0 - BrTable1)/2) DCB ((P1 - BrTable1)/2)
Now, my understanding is as follows –
TBB [PC,R1] will try to look for BrTable1 at PC + 4 (next instruction). Instead of PC , I can also give BrTable1 pointer her . R1 is counter and for next N cycles depending on R1 possible values, it will have cases.
Branching will happen as : PC_new = (BrTable1_pointer) + 2 * (data written at BrTable1_pointer + R1)) whereas R1 will be as a up-counter from 0 to X (For 8 bit, X = 255)
For R1 = 0 , DCB ((P0 - BrTable1)/2) will - Branch my code to (BrTable1 + 2 * ((P0 - BrTable1)/2)) Branch my code to (BrTable1 + (P0 - BrTable1)) Branch my code to P0
Now this is as per expectation also.
Query –
Intention is to compare the value of R1 and accordingly branch .
- Is my understanding correct ?
- If I want to write only 2 cases for R1 == 0 and R1 == 10 then should I write my DCB instruction at ( BrTable1 + 10 ) location or is there any method to write it in next instruction only ?
- Do I have any control on R1 ?
Description
Thanks !
Lalit Arora is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.