So I tried compiling this code below but keep getting the 1176E error message of

Branch offset out of range 0xFFFFFFE8 out of range permitted values are up to 0x00007E

on the 5th code line. I read the error description on ARM site but can't make since of it. I think it my be something to do with the fact that this code is in a sub procedure maybe? Anyways it looks like using rout can help, but I am not sure how to implement that instruction in the code below and what pushes the PC out of range in the first place?
Can anyone shed light on how to use rout in this case to subvert the error?

powerCount           PROC
                     MOV r4 , r1              // get a copy of test value 
                     MOV r9, #10              // make a divisor
                     MOV  r3, #0              // initialize a counter
loop3                CBZ r4, check            // check loop condition
                     ADD r3, r3, #1           // record the number of di 
                     SDIV r4, r9              // divide the value toward 
                     B loop3
  • 1
    \$\begingroup\$ Conditional branches in 16 bit thumb do have a narrow range but it would seem that your offset (at least if we can interpret it as a signed displacement, otherwise it would be absurd) is within that. You could use CBZ.W for a 32-bit encoding but it's not really clear why what you have does not work. Which assembler with what settings in what mode targeting exactly what processor type? Where is "check"? \$\endgroup\$ – Chris Stratton Mar 8 at 6:57
  • 3
    \$\begingroup\$ You seem to have asked a number of less than clear and not well presented questions on ARM assembly over the course of the past day. Don't just abandon the old ones, fix the issues they have which were pointed out. \$\endgroup\$ – Chris Stratton Mar 8 at 7:00
  • 1
    \$\begingroup\$ I deduce check is over 128 instructions away, as per the first comment. (or some other small number). \$\endgroup\$ – Sean Houlihane Mar 8 at 8:55
  • \$\begingroup\$ @chris Stratton ya sorry I’ve fixed as I have gone just a noob so I feel like it’s hard to narrow down exactly what I need to ask cause I have such vague understanding of assembly language, but your CBZ.W made it work thanks the above was a sub procedure which I guess had something to do with it still unclear why \$\endgroup\$ – mac Mar 8 at 12:23
  • \$\begingroup\$ As Sean pointed out above already, the 'why' is that check is too 'far away' for the CBZ r4, check instruction to be able to reach. CBZ.W has a much larger range, so that instruction works. \$\endgroup\$ – brhans Mar 8 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.