This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARM mode Thumb mode switching

Note: This was originally posted on 13th January 2011 at http://forums.arm.com

Hi,

Let me explain my problem,
i come across one situation

cmp r1,#0
beq labels_of1

i would like to merge both the instructions in to one. for that i would like to use cbz (thumb instruction)

but my compiler shows an error message that this particular instruction not present in the Instruction.

Since the instruction is cbz the compilation should be in thum mode. how can i modify my make file and how can i switch the mode from ARM to thumb for execute the optimized instruction.

please let me know the mode change needs any extra cycle.


Rgds
Dave
Parents
  • Note: This was originally posted on 19th January 2011 at http://forums.arm.com

    Assuming you've got sufficient scratch registers, or time to free them; you could try something like:

      ; r0 = a0
      ; r1 = b0
      ; r2 = c0
      ; r3 = scratch
      ; r4 = scratch
     
      SUB     r3,r0,r1
      SUB     r4,r1,r2
      ADDS    r3,r3,#(25-1)
      ADDS    r4,r4,#(30-1) 
      CMP     r3,#(2*(25-1))
      SUB     r3,r2,r0
      CMPLS   r4,#(2*(30-1))
      ADD     r3,r3,#(45-1)
      BHI     Take_None   // modify none
      CMP     r3,#(2*(45-1))
      BHI     Take_Second // modify a0,b0
      B       Take_First  // modify a0,b0,c0


    (Obviously the final branch could be omitted).

    hth
    s.
Reply
  • Note: This was originally posted on 19th January 2011 at http://forums.arm.com

    Assuming you've got sufficient scratch registers, or time to free them; you could try something like:

      ; r0 = a0
      ; r1 = b0
      ; r2 = c0
      ; r3 = scratch
      ; r4 = scratch
     
      SUB     r3,r0,r1
      SUB     r4,r1,r2
      ADDS    r3,r3,#(25-1)
      ADDS    r4,r4,#(30-1) 
      CMP     r3,#(2*(25-1))
      SUB     r3,r2,r0
      CMPLS   r4,#(2*(30-1))
      ADD     r3,r3,#(45-1)
      BHI     Take_None   // modify none
      CMP     r3,#(2*(45-1))
      BHI     Take_Second // modify a0,b0
      B       Take_First  // modify a0,b0,c0


    (Obviously the final branch could be omitted).

    hth
    s.
Children
No data