Skip to contentSkip to conversation

e300 (MPC5121) dlmzb

DISCUSSION Fortini Matteo 2 participants 2 messages Sep 25, 2009

lore
Share & tools
lore
#0 lore raw

I was trying to insert an optimized strlen() function using the following code taken from the ibm site on an MPC5121, but it crashes the kernel. Is it because it's an unsupported op, or because I'm missing some needed steps?

Thank you,
Matteo

_GLOBAL(strlen)

   addi   r4,0,8    // Load byte count of 8
   mtxer  r4        // Set byte count for load string
   xor    r4,r4,r4  // r4 = 0, r4 == accumulator
1:
   lswx   r5,r3,r4  // load string into r5 & r6
   dlmzb. r12,r5,r6 // find NULL byte and record in r7.
   add    r4,r4,r12 // Update accumulator.
   beq    1b        // Loop if NULL not found.
   addi   r3,r4,-1  // Subtract 1 for NULL byte.

blr // Return length

#1 lore raw
Quoted 16 lines · Fortini Matteo

I was trying to insert an optimized strlen() function using the following code taken from the ibm site on an MPC5121, but it crashes the kernel. Is it because it's an unsupported op, or because I'm missing some needed steps?

Thank you,
Matteo

_GLOBAL(strlen)

  addi   r4,0,8    // Load byte count of 8
  mtxer  r4        // Set byte count for load string
  xor    r4,r4,r4  // r4 = 0, r4 == accumulator
1:
  lswx   r5,r3,r4  // load string into r5 & r6
  dlmzb. r12,r5,r6 // find NULL byte and record in r7.
  add    r4,r4,r12 // Update accumulator.
  beq    1b        // Loop if NULL not found.
  addi   r3,r4,-1  // Subtract 1 for NULL byte.
Quoted 1 line

blr // Return length

dlmzb. isn't supported on e300. I believe only 4xx supports it.

- k