News for hackers. Stuff that matters.
Re:Evolutionary algorithm to find Quake III's fast inverse s... by s-macke on Tuesday April 08, 2014 @06:51PM (#7556532)
This reminds of another trick on the C64 to multiply two 8 Bit numbers a*b = [ ((a+b)/2)^2 - ((a-b)/2)^2 ]

more or less: one 8 bit additon, one 8 bit subtraction, two table lookups for the squares and one 16 bit subtraction.

Re:Evolutionary algorithm to find Quake III's fast inverse s... by bane on Tuesday April 08, 2014 @09:57PM (#7557292)
Were the divide by twos just bit shift operations? (I have no idea if the 6510 had bit shift operators.)
Re:Evolutionary algorithm to find Quake III's fast inverse s... by muyuu on Wednesday April 09, 2014 @06:40AM (#7558573)
Yep, it does.

ROL rotate left

ROR rotate right

ASL arithmetic shift left

LSR logic shift right

But for it to work for all 2-complement coded values we need to ensure that the MSB is copied back into itself to keep the value the same sign, which can be done with another shift.

; Divide a signed 16-bit value by 2

        LDA MEM+1    ;Load the MSB

        ASL A        ;Copy the sign bit into C

        ROR MEM+1    ;restore MSB

        ROR MEM+0    ;Rotate the LSB

It's a bunch of cycles but nothing compared to a generic division.
Re:Evolutionary algorithm to find Quake III's fast inverse s... by s-macke on Tuesday April 08, 2014 @10:09PM (#7557321)
Well, I think it is part of the table.

http://codebase64.org/doku.php?id=base:fast_8bit_multiplicat...

But the C64 had also a shifting operation.