Path: chuka.playstation.co.uk!news From: raasch@fh-worms.de (Michael Raasch) Newsgroups: scee.yaroze.programming.codewarrior Subject: where are the differences? Date: Tue, 12 Aug 1997 00:55:55 +0200 Organization: Michael Raasch Softwareentwicklung Lines: 61 Message-ID: NNTP-Posting-Host: port11.Fh-Worms.DE X-Newsreader: Anawave Gravity v1.10.570 Hi there Codewarriors. these are some lines of my fireroutine and I wonder why Codewarrior generates such a different code that the version described as "fastest" is 23 scanlines faster than the "faster"-version. As you can see, the only difference is the p++ written in an extra line compared to the other version where everything is compacted into one expression. --- snip --- #define FIRE_WIDTH 80 #define FIRE_HEIGHT 50 u_char imgFire[FIRE_WIDTH][FIRE_HEIGHT]; u_char fadetable[256]; register u_short i; register u_char *p; p = &imgFire[1][0]; for (i = 0; i < FIRE_WIDTH * FIRE_HEIGHT; i++) { // faster // *(p - FIRE_WIDTH) = fadetable[(*(p - 1) + *p + *(p + 1) + *(p + FIRE_WIDTH)) >> 2]; // p++; // fastest *(p++ - FIRE_WIDTH) = fadetable[(*(p - 1) + *p + *(p + 1) + *(p + FIRE_WIDTH)) >> 2]; } --- snap --- I also tried another trick with some more register-variables: register u_char left, middle, right; p = &imgFire[1][0]; left=*(p-1); middle=*p; for (i = 0; i < FIRE_WIDTH * FIRE_HEIGHT; i++) { right=*(p+1); *(p - FIRE_WIDTH) = fadetable[(left+middle+right + *(p + FIRE_WIDTH)) >> 2]; left=middle; middle=right; p++; } now it takes only 2 memoryreads but it takes much longer to execute. Even with the register-variables. So, how many variables can CW fit into the 32 registers? And now about the D-Cache. Does it make any difference when accessing it by BYTE, WORD or LONG? -- hasta la pasta, .\\ichael "Wenn das John Wayne noch erlebt haette..."