Note: This is PowerPC assembler - I hope it isn't too difficult to decipher - if all else fails, consult
http://developer.apple.com/library/mac/ ... tions.html.
Stockfish:
Code: Select all
__Z3msby:
mflr r0
LBB20:
LBB21:
cmplwi cr7,r3,0
LBE21:
LBE20:
mr r10,r4
bcl 20,31,"L00000000003$pb"
"L00000000003$pb":
LBB22:
LBB23:
li r11,0
LBE23:
LBE22:
mflr r8
mtlr r0
LBB24:
LBB25:
ble cr7,L9
li r11,32
mr r10,r3
L9:
cmplwi cr7,r10,65535
mr r0,r10
ble cr7,L10
srwi r0,r10,16
addi r11,r11,16
L10:
cmplwi cr7,r0,255
ble cr7,L12
srwi r0,r0,8
addi r11,r11,8
L12:
addis r2,r8,ha16(__ZN17_GLOBAL__N_RMasks9MS1BTableE-"L00000000003$pb")
slwi r0,r0,2
la r2,lo16(__ZN17_GLOBAL__N_RMasks9MS1BTableE-"L00000000003$pb")(r2)
lwzx r3,r2,r0
LBE25:
LBE24:
add r3,r11,r3
blr
24 instructions :
5 branch instructions,
3 compare instructions,
4 ADD instructions,
3 rotate left instructions,
4 load instructions,
5 move instructions.
Gerd #1:
Code: Select all
__Z3msby:
LBB20:
LBB21:
cmpwi cr7,r3,0
beq cr7,L6
cntlzw r0,r3
xori r3,r0,63
blr
L6:
cmpwi cr7,r4,0
li r3,0
cntlzw r0,r4
xori r3,r0,31
LBE21:
LBE20:
blr
11 instructions :
2 compare instructions,
4 branch instructions,
1 load instruction,
2 XOR instructions,
2 Leading Zero Count instructions.
Gerd #2 (I modified it to return 0 if it gets a null bitboard - shouldn't be too costly) :
Code: Select all
__Z3msby:
mr r9,r3
LBB20:
li r3,0
or. r0,r9,r4
beqlr cr0
cmplwi cr7,r9,0
ble cr7,L13
cntlzw r0,r9
xori r3,r0,63
blr
L13:
cntlzw r0,r4
xori r3,r0,31
LBE20:
blr
12 instructions :
4 branch instructions,
2 Count Leading Zeroes instructions,
2 XOR instructions,
1 load instruction,
1 compare instruction,
1 OR instruction,
1 move instruction.
Gerd #3 (same modification as above):
Code: Select all
__Z3msby:
mr r10,r3
LBB20:
LBB21:
li r3,0
or. r0,r10,r4
beqlr cr0
cntlzw r9,r10
cntlzw r11,r4
addi r0,r9,-32
srawi r0,r0,31
andc r0,r11,r0
add r9,r9,r0
xori r3,r9,63
LBE21:
LBE20:
blr
12 instructions:
1 move instruction,
1 load instruction,
1 OR instruction,
2 branch instruction,
2 count leading zeroes instructions,
2 ADD instructions,
1 rotate instruction,
1 AND instruction,
1 XOR instruction.
Benchmark results to be posted shortly.
Matthew:out
Some believe in the almighty dollar.
I believe in the almighty printf statement.