mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-01-11 09:29:51 +00:00
tfv: inline the signed multiply
This commit is contained in:
parent
fa45d4bd72
commit
51befa0f01
@ -333,11 +333,18 @@ static void init_table(void) {
|
||||
|
||||
static unsigned int product[4];
|
||||
|
||||
static int fixed_mul_unsigned(
|
||||
unsigned char x_i, unsigned char x_f,
|
||||
unsigned char y_i, unsigned char y_f,
|
||||
static void fixed_mul(unsigned char x_i, unsigned char x_f,
|
||||
unsigned char y_i, unsigned char y_f,
|
||||
unsigned char *z_i, unsigned char *z_f,
|
||||
int debug, int reuse) {
|
||||
int reuse) {
|
||||
|
||||
int debug=0;
|
||||
|
||||
//static int fixed_mul_unsigned(
|
||||
// unsigned char x_i, unsigned char x_f,
|
||||
// unsigned char y_i, unsigned char y_f,
|
||||
// unsigned char *z_i, unsigned char *z_f,
|
||||
// int debug, int reuse) {
|
||||
|
||||
// <T1 * <T2 = AAaa
|
||||
// <T1 * >T2 = BBbb
|
||||
@ -551,24 +558,24 @@ static int fixed_mul_unsigned(
|
||||
// printf("DDdd %02x:%02x\n",_DD,_dd);
|
||||
// }
|
||||
|
||||
cycles.multiply+=6;
|
||||
// cycles.multiply+=6;
|
||||
|
||||
return (product[3]<<24)|(product[2]<<16)|(product[1]<<8)|product[0];
|
||||
// return (product[3]<<24)|(product[2]<<16)|(product[1]<<8)|product[0];
|
||||
// rts ; 6
|
||||
}
|
||||
//}
|
||||
|
||||
/* signed */
|
||||
static void fixed_mul(unsigned char x_i, unsigned char x_f,
|
||||
unsigned char y_i, unsigned char y_f,
|
||||
unsigned char *z_i, unsigned char *z_f, int reuse) {
|
||||
//static void fixed_mul(unsigned char x_i, unsigned char x_f,
|
||||
// unsigned char y_i, unsigned char y_f,
|
||||
// unsigned char *z_i, unsigned char *z_f, int reuse) {
|
||||
|
||||
int a,c;
|
||||
|
||||
fixed_mul_unsigned(x_i,x_f,y_i,y_f,z_i,z_f,0,reuse);
|
||||
// jsr multiply_16bit_unsigned ; 6
|
||||
|
||||
// fixed_mul_unsigned(x_i,x_f,y_i,y_f,z_i,z_f,0,reuse);
|
||||
// jsr multiply_16bit_unsigned ;
|
||||
|
||||
a=(x_i&0xff); // lda T1+1 ; 3
|
||||
cycles.multiply+=12;
|
||||
cycles.multiply+=6;
|
||||
if ((a&0x80)==0) goto x_positive; // bpl :+ ;^3/2nt
|
||||
|
||||
c=1; // sec ; 2
|
||||
|
@ -719,10 +719,15 @@ static void init_table(void) {
|
||||
|
||||
static unsigned int product[4];
|
||||
|
||||
int fixed_mul_unsigned(int x_i,int x_f,
|
||||
int fixed_mul(int x_i,int x_f,
|
||||
int y_i, int y_f,
|
||||
int *z_i, int *z_f,
|
||||
int debug) {
|
||||
|
||||
//int fixed_mul_unsigned(int x_i,int x_f,
|
||||
// int y_i, int y_f,
|
||||
// int debug) {
|
||||
|
||||
// <T1 * <T2 = AAaa
|
||||
// <T1 * >T2 = BBbb
|
||||
// >T1 * <T2 = CCcc
|
||||
@ -935,20 +940,20 @@ int fixed_mul_unsigned(int x_i,int x_f,
|
||||
// printf("DDdd %02x:%02x\n",_DD,_dd);
|
||||
// }
|
||||
|
||||
return 0;
|
||||
// return 0;
|
||||
//(product[3]<<24)|(product[2]<<16)|(product[1]<<8)|product[0];
|
||||
// rts ; 6
|
||||
}
|
||||
//}
|
||||
|
||||
/* signed */
|
||||
int fixed_mul(int x_i,int x_f,
|
||||
int y_i, int y_f,
|
||||
int *z_i, int *z_f,
|
||||
int debug) {
|
||||
//int fixed_mul(int x_i,int x_f,
|
||||
// int y_i, int y_f,
|
||||
// int *z_i, int *z_f,
|
||||
// int debug) {
|
||||
|
||||
int a,c;
|
||||
// int a,c;
|
||||
|
||||
fixed_mul_unsigned(x_i,x_f,y_i,y_f,debug);
|
||||
// fixed_mul_unsigned(x_i,x_f,y_i,y_f,debug);
|
||||
// jsr multiply_16bit_unsigned ; 6
|
||||
|
||||
a=(x_i&0xff); // lda T1+1 ; 3
|
||||
|
@ -170,5 +170,21 @@ Remove unneeded precision in the 8.8 x 8.8 fixed point multiply
|
||||
Total = 187,189
|
||||
Frame Rate = 5.34 fps
|
||||
|
||||
In-line unsigned multiply inside of signed multiply (save 12 cycles)
|
||||
Multiplying 1.0 * 2.0 = 2.0, took 198 cycles
|
||||
Multiplying ff.ff * ff.ff = 0.0, took 218 cycles
|
||||
|
||||
Cycles: flying= 187
|
||||
Cycles: getkey= 46
|
||||
Cycles: page_flip= 26
|
||||
Cycles: multiply= 40,888
|
||||
Cycles: mode7= 118,034
|
||||
Cycles: lookup_map= 22,747
|
||||
Cycles: put_sprite= 2,561
|
||||
================================
|
||||
Total = 184,489
|
||||
Frame Rate = 5.42 fps
|
||||
|
||||
|
||||
Each cycle removed from inner X loop saves
|
||||
32*40=1280 cycles
|
||||
|
@ -114,7 +114,9 @@ second_table:
|
||||
; ----------
|
||||
; RESULT
|
||||
|
||||
fixed_16x16_mul_unsigned:
|
||||
;fixed_16x16_mul_unsigned:
|
||||
|
||||
multiply:
|
||||
|
||||
bcc num1_same_as_last_time ; 2nt/3
|
||||
|
||||
@ -290,16 +292,16 @@ dd_no_carry2:
|
||||
; *z_i=product[1];
|
||||
; *z_f=product[0];
|
||||
|
||||
rts ; 6
|
||||
; rts ; 6
|
||||
|
||||
|
||||
;=================
|
||||
; Signed multiply
|
||||
;=================
|
||||
|
||||
multiply:
|
||||
;multiply:
|
||||
|
||||
jsr fixed_16x16_mul_unsigned ; 6
|
||||
; jsr fixed_16x16_mul_unsigned ; 6
|
||||
|
||||
lda NUM1H ; x_i ; 3
|
||||
;===========
|
||||
|
Loading…
x
Reference in New Issue
Block a user