Author Topic: Fast Bit Reversal algorithm  (Read 13998 times)

Siekmanski

  • Member
  • *****
  • Posts: 2555
Re: Fast Bit Reversal algorithm
« Reply #15 on: March 26, 2016, 08:26:45 PM »
I finished a routine that calculates 16 to 1024 size tables.
The algorithm works but I don't have enough registers to calculate larger then 1024 size tables. ( at least I think so.... )
I may need to store temporary pre calculated column values inside the table memory to calculate larger power of 2 size tables.

After all the goal is, to use this algorithm to calculate very large tables as fast as possible.

Edit: see Reply #26 for the source code
« Last Edit: March 28, 2016, 02:27:42 AM by Siekmanski »
Creative coders use backward thinking techniques as a strategy.

nidud

  • Member
  • *****
  • Posts: 2388
    • https://github.com/nidud/asmc
Re: Fast Bit Reversal algorithm
« Reply #16 on: March 26, 2016, 11:04:57 PM »
deleted
« Last Edit: February 25, 2022, 11:22:57 AM by nidud »

jj2007

  • Member
  • *****
  • Posts: 12933
  • Assembler is fun ;-)
    • MasmBasic
Re: Fast Bit Reversal algorithm
« Reply #17 on: March 27, 2016, 06:34:16 AM »
Works fine for me on Win7-64, even if launched directly from the archive.

Siekmanski

  • Member
  • *****
  • Posts: 2555
Re: Fast Bit Reversal algorithm
« Reply #18 on: March 27, 2016, 03:04:30 PM »
Hi Nidud,
Can't find what could cause this....
Creative coders use backward thinking techniques as a strategy.

jj2007

  • Member
  • *****
  • Posts: 12933
  • Assembler is fun ;-)
    • MasmBasic
Re: Fast Bit Reversal algorithm
« Reply #19 on: March 27, 2016, 07:05:29 PM »
Could be unaligned access. @Nidud: If you configure Olly as just-in-time debugger, where does it crash?7
->Options/debugging/just-in-time

Siekmanski

  • Member
  • *****
  • Posts: 2555
Re: Fast Bit Reversal algorithm
« Reply #20 on: March 27, 2016, 08:39:55 PM »
Memory access is 16 byte aligned.
Creative coders use backward thinking techniques as a strategy.

jj2007

  • Member
  • *****
  • Posts: 12933
  • Assembler is fun ;-)
    • MasmBasic
Re: Fast Bit Reversal algorithm
« Reply #21 on: March 27, 2016, 09:03:07 PM »
In fact, I can't produce a crash, whatever I try ::)

nidud

  • Member
  • *****
  • Posts: 2388
    • https://github.com/nidud/asmc
Re: Fast Bit Reversal algorithm
« Reply #22 on: March 27, 2016, 10:16:05 PM »
deleted
« Last Edit: February 25, 2022, 11:23:10 AM by nidud »

jj2007

  • Member
  • *****
  • Posts: 12933
  • Assembler is fun ;-)
    • MasmBasic
Re: Fast Bit Reversal algorithm
« Reply #23 on: March 27, 2016, 10:46:01 PM »
It could be a hardware problem. The CPU is <= SSE3.

movdqa is SSE2. Besides, Olly is powerful but it can't upgrade the hardware :icon_mrgreen:

nidud

  • Member
  • *****
  • Posts: 2388
    • https://github.com/nidud/asmc
Re: Fast Bit Reversal algorithm
« Reply #24 on: March 27, 2016, 11:42:46 PM »
deleted
« Last Edit: February 25, 2022, 11:23:21 AM by nidud »

nidud

  • Member
  • *****
  • Posts: 2388
    • https://github.com/nidud/asmc
Re: Fast Bit Reversal algorithm
« Reply #25 on: March 27, 2016, 11:46:13 PM »
deleted
« Last Edit: February 25, 2022, 11:23:29 AM by nidud »

Siekmanski

  • Member
  • *****
  • Posts: 2555
Re: Fast Bit Reversal algorithm
« Reply #26 on: March 28, 2016, 02:26:01 AM »
Nidud.

Thanks, for finding this bug, xmm4 is indeed undefined when it jumps to NextColumn.  :t
Creative coders use backward thinking techniques as a strategy.

jj2007

  • Member
  • *****
  • Posts: 12933
  • Assembler is fun ;-)
    • MasmBasic
Re: Fast Bit Reversal algorithm
« Reply #27 on: May 28, 2016, 07:40:57 PM »
Here is a slow but easy-to-use MirrorBits() macro ruthlessly stolen from The Aggregate at University of Kentucky :biggrin:

Code: [Select]
include \masm32\MasmBasic\MasmBasic.inc

MirrorBits MACRO arg32
  ifdifi <arg32>, <eax>
mov eax, arg32
  endif
  mov edx, eax
  and eax, 0aaaaaaaah
  and edx, 055555555h
  shr eax, 1
  add edx, edx ; shl edx,1
  or eax, edx
  mov edx, eax
  and eax, 0cccccccch
  and edx, 033333333h
  shr eax, 2
  lea edx, [4*edx] ; shl edx, 2
  or eax, edx
  mov edx, eax
  and eax, 0f0f0f0f0h
  and edx, 0f0f0f0fh
  shr eax, 4
  shl edx, 4
  or eax, edx
  mov edx, eax
  and eax, 0ff00ff00h
  and edx, 0ff00ffh
  shr eax, 8
  shl edx, 8
  or eax, edx
  mov edx, eax
  shr eax, 16
  shl edx, 16
  or eax, edx
  EXITM <eax>
ENDM

  Init
  push 29
  .Repeat
mov ecx, Rand(-1)
Print Bin$(ecx), " "
Print Bin$(MirrorBits(ecx)), CrLf$
dec stack
  .Until Sign?
EndOfCode

Code: [Select]
01110011101010011011100010001101 10110001000111011001010111001110
00010010011100011100110110011101 10111001101100111000111001001000
00100010111111101000101011011000 00011011010100010111111101000100
11011101000111011011100110100010 01000101100111011011100010111011
10100111111001110100000001001101 10110010000000101110011111100101
11010010000110000100011110110011 11001101111000100001100001001011
00111000011011011111010011000100 00100011001011111011011000011100
11001001100100010111001100000000 00000000110011101000100110010011
00000101111100101101011011111111 11111111011010110100111110100000
10000100010101101000011100001011 11010000111000010110101000100001
10010000000000000001001101011000 00011010110010000000000000001001
01011101011001101111011010001110 01110001011011110110011010111010
10010011101011101110101110101000 00010101110101110111010111001001
10101101000101100011100110111011 11011101100111000110100010110101
01000000010110111111100100100000 00000100100111111101101000000010
00100101011010000101111100010001 10001000111110100001011010100100
10010110110101010011100001110000 00001110000111001010101101101001
01110101111111110011100000101011 11010100000111001111111110101110
10110000001000010110001101110101 10101110110001101000010000001101
11111010101001110110111110011110 01111001111101101110010101011111
10100011100111111110111110100101 10100101111101111111100111000101
00101010000111001010100011010010 01001011000101010011100001010100
11010111001111101100100000011010 01011000000100110111110011101011
00011111101110101101101000110110 01101100010110110101110111111000
00111011101111100100110101000001 10000010101100100111110111011100
11000110101010111001011101011011 11011010111010011101010101100011
11100000111010001101111101101111 11110110111110110001011100000111
11110100001001100111100101101011 11010110100111100110010000101111
11110000110000101110100111011111 11111011100101110100001100001111
01100100111110010100110110001110 01110001101100101001111100100110
« Last Edit: July 30, 2020, 06:43:00 PM by jj2007 »