From: David H. <ac...@lo...> - 2003-10-31 13:37:23
|
OK Michael, You are right, that is quite a bit better looking code. I do like the stack initialization / finalization code for subroutines that are used for this compiler (a big complaint with the *old* Hi-Tech compiler; 0000 DD E5 50 push ix 0002 DD 21 00 00 51 ld ix,#0 0006 DD 39 52 add ix,sp and the comparison between 'int's is pretty tight as well; 0063 FD 21r00s00 149 ld iy,#_timing_j_1_1 < here IX is the stack ptr. and we are comparing to a value on the stack > 0060 DD 7E 04 148 ld a,4(ix) 0067 FD 96 00 150 sub a,0(iy) 006A DD 7E 05 151 ld a,5(ix) 006D FD 9E 01 152 sbc a,1(iy) 0070 DAr87s00 153 jp c,00111$ The compiler wisely used register colouring to get rid of one variable (unsigned char), and allocated space for the other int. I see from the code that indeed this temporary variable gets put into the data segment, something I like a lot better than using the stack for variables in subroutines of real small stack systems: 17 .area _DATA 0000 18 _timing_j_1_1: 0000 19 .ds 2 <BTW for readers seeing this thread anew, the 'C' code that this asm is taken from is: void timing( unsigned int timeval ) { static unsigned int j; unsigned char i, k; for ( j = 1; j <= timeval; j++ ) for ( i = 1; i <= 7; i++ ) { if ( interrupted ) k = 1; } } :-) > The question all this brings to mind is: Is there a way to control what segment these temporary variables are assigned from? As I can see, this goes into the DATA segment. And I can't think of a better area, but a nagging doubt comes to mind that warns me that w/out overlaying some of this data area, I could be getting into trouble. I *know* there are issues with this, and Paul was bringing up one solution, but if there were a way to allow the coder to specify what data area could be safely overlayed with another in subroutine calls, we *may* be able to save data space allocation... -David Ni-Wumpf ltd. |