PKHTB instruction on beagle board using CCS compiler

Hi,

Iam using Beagle board Rev C3 with CCS 4.0.2 ,CG tools version 4.6.1,
compiler TMS470 for cortex A8 device. I have ported ARM11 code on this
board. The following instruction is not behaving as expected.

     PKHTB r0, r9, r0
  src r0-> 0xffffffb4
        r9->0x000c0000

  dst r0-> 0x000cffb4

This instruction packs top 16 bits of r9, bottom 16 bits of r0 and the
result is moved to r0. values in src registers and expected result is
given above.

Instead of having the above result, i got 0x000cffff in the
destination reg r0.

How can i get the correct result in reg r0 using the PKHTB instruction.

chandu <chanducnu@gmail.com> writes:

Hi,

Iam using Beagle board Rev C3 with CCS 4.0.2 ,CG tools version 4.6.1,
compiler TMS470 for cortex A8 device. I have ported ARM11 code on this
board. The following instruction is not behaving as expected.

     PKHTB r0, r9, r0
  src r0-> 0xffffffb4
        r9->0x000c0000

  dst r0-> 0x000cffb4

This instruction packs top 16 bits of r9, bottom 16 bits of r0 and the
result is moved to r0. values in src registers and expected result is
given above.

Instead of having the above result, i got 0x000cffff in the
destination reg r0.

How can i get the correct result in reg r0 using the PKHTB instruction.

It looks like you're getting the PKHTB r0, r9, r0, asr #16 instruction.
Disassemble your binary and see if that is the case. Pasting your
actual code here would perhaps allow someone to see if you've made a
mistake somewhere.

Thanks for the quick reply. Iam adding my code and equivalent
disassembly code below.

actual code:

  .global temp_func

numberabc .word 0xffffffb4
numberabc1 .word 0xc0000
temp_func:

  LDR r0, numberabc
  LDR r9, numberabc1

  PKHTB r0, r9, r0

  .ENDASMFUNC

disassembly shows the following code

          numberabc:
80873b0c: FFFFFFB4 .word 0xFFFFFFB4
          numberabc1:
80873b10: 000C0000 ANDEQ R0, R12, R0

          $../asm/:569:574$, temp_func:
80873b14: E51F0010 LDR R0, numberabc
80873b18: E51F9010 LDR R9, numberabc1
80873b1c: E6890050 PKHTB R0, R9, R0, ASR, #0

  Inspite of having a shift value of 0, iam getting the wrong result.

Thanks in advance.

Your assembler is doing something wrong: pkhtb with no shift
should be assembled as pkhbt. And your disassembler is wrong
too since E6890050 is PKHTB r0,r9,r0,ASR #32.

HTH,

Laurent

Laurent Desnogues <laurent.desnogues@gmail.com> writes:

Thanks a lot for your replies. i tried using pkhbt instruction. it
works.

Thaks a lot for taking time to aswer this post.