Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Bitmap management for ARM-7

Name: Anonymous 2008-11-14 3:55

I haven't found any suitable log-like assembly instruction... so I've wrote this. Are you up to you to make it better? Maybe it could be improved by reading...


.code 32
.text
.align 0

  .global dw_bmp_msb_pos
dw_bmp_msb_pos:
  movs r1, r0
  moveq r0, #0
  bxeq lr
  mov r0, #33
getmsb_cycle:
  sub r0, r0, #1
  movs r1, r1, lsl #1
  bxcs lr
  b getmsb_cycle

  .global dw_bmp_set
dw_bmp_set:
  ldr r2, [r0, #0]
  mov r3, #1
  mov r3, r3, lsl r1
  orr r2, r2, r3
  str r2, [r0, #0]
  bx lr

  .global dw_bmp_reset
dw_bmp_reset:
  ldr r2, [r0, #0]
  mov r3, #1
  mov r3, r3, lsl r1
  bic r2, r2, r3
  str r2, [r0, #0]
  bx lr

Name: Anonymous 2008-11-14 14:24

>>9
[m]A6.7.24 CLZ
Count Leading Zeros returns the number of binary zero bits before the first binary one bit in a value.

Encoding T1 ARMv6T2, ARMv7
CLZ<c> <Rd>,<Rm>
151413121110 9 8 7 6 5 4 3 2 1 0 151413121110 9 8 7 6 5 4 3 2 1 0
1 1 1 1 1 0 1 0 1 0 1 1 Rm       1 1 1 1 Rd      1 0 0 0 Rm

if !Consistent(Rm) then UNPREDICTABLE;
d = UInt(Rd);  m = UInt(Rm);
if BadReg(d) || BadReg(m) then UNPREDICTABLE;
 
Assembler syntax
CLZ<c><q>  <Rd>, <Rm>
where:
<c><q> See Standard assembler syntax fields on page A6-7.
<Rd> Specifies the destination register.
<Rm> Specifies the register that contains the operand. Its number must be encoded twice in
encoding T1, in both the Rm and Rm2 fields.
Operation
if ConditionPassed() then
    EncodingSpecificOperations();
    result = CountLeadingZeroBits(R);
    R[d] = result<31:0>;
Exceptions
None.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List