shadow1013 Posted May 10, 2011 #ifdef __WATCOMC__ #pragma aux FixedMul = \ "imul ebx", \ "shrd eax,edx,16" \ parm [eax] [ebx] \ value [eax] \ modify exact [eax edx] #pragma aux FixedDiv2 = \ "cdq", \ "shld edx,eax,16", \ "sal eax,16", \ "idiv ebx" \ parm [eax] [ebx] \ value [eax] \ modify exact [eax edx] #endif ^ the above is what vanilla doom used to do fixed division. EDIT: and multiplication. sorry about the long lateness. didnt realize how long ago this thread was 0 Share this post Link to post
Maes Posted May 10, 2011 No problems :-) Since I resumed working on it, I also am interested in accuracy aspects. Apart from the forced cast to floating point present in the linuxdoom codebase, there seems to be another thing which does not add up to your Watcom disassembly. The code currently used in Mocha Doom for the first part of FixedDiv is this one: // FixedDiv, Mocha Doom version public final static int FixedDiv (int a, int b ) { if ((Math.abs(a) >> 14) >= Math.abs(b)) { return (a^b) < 0 ? Integer.MIN_VALUE : Integer.MAX_VALUE; } else { long result; result = ((long) a << 16) / b; return (int) result; } } which is actually based on Chocolate Doom's code. The "abs check" bit is also present in the linux doom code: // // FixedDiv, C version. // fixed_t FixedDiv (fixed_t a,fixed_t b) { if ( (abs(a)>>14) >= abs(b)) return (a^b)<0 ? MININT : MAXINT; return FixedDiv2 (a,b); } Could you provide a disassembly of FixedDiv "1" for comparison? I'm asking because in the development branch of Mocha Doom, _D_ claimed that the abs check had to be commented out because it caused problems in various situations. So is it supposed to be part of the vanilla codebase or is it something that crept it afterwards? 0 Share this post Link to post
shadow1013 Posted May 10, 2011 That is not dissasembly but rather taken from the hexen sources which provided those macros, it has identical instructions as the released linux doom assembler, where as fixeddiv, is the same function released c, just fixeddiv(1) calls fixeddiv2 after the abs check 0 Share this post Link to post
Recommended Posts