ver 8.3 other code bloating sources

Beta Testing discussion on mikroPascal.
Post Reply
Author
Message
janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

ver 8.3 other code bloating sources

#1 Post by janni » 11 Jul 2008 15:41

Code generated by v 8.3 is finally similar in size to that produced by v 7 :D . Wouldn't it be great, though, if better code optimisation could be achieved?

Here's what I found comparing the assembly produced by v 8.3 to the one resulting from compilation with v 7:

1. For unknown reason instructions involving access bank variables are preceeded by bank switching to bank 0, thus destroying effects of both automatic and manual optimisations in variable placement :cry: .

Code: Select all

$7A34	$0100	    	MOVLB	0
$7A36	$0E32	    	MOVLW	50
$7A38	$6ECD	    	MOVWF	T1CON, 0
2. In some places GOTO is used where BRA would suffice:

Code: Select all

$85D8	$EFEF	F042	GOTO	LCDproc_L_70
$85DC	$	LCDproc_L_69:
$85DC	$2BB0	    	INCF	_washsv, 1, 1
$85DE	$	LCDproc_L_70:
3. Superflous movff instructions are being added

Code: Select all

$A0FA	$C10A	F000	MOVFF	FARG_Flash_Read+1, STACK_0
$A0FE	$C10B	F001	MOVFF	FARG_Flash_Read+2, STACK_0+1 // these two instructions
$A102	$C10C	F002	MOVFF	FARG_Flash_Read+3, STACK_0+2 // are obviously not needed
$A106	$C000	FFF7	MOVFF	STACK_0, TBLPTRH
$A10A	$C10B	F000	MOVFF	FARG_Flash_Read+2, STACK_0
$A10E	$C000	FFF8	MOVFF	STACK_0, TBLPTRU
$A112	$0008	    	TBLRD*
4. 'phantom variable' effect occurs, i.e. bank switching for a variable that isn't there (mentioned in my earlier post).

All the above didn't take place in version 7 (or did but to much smaller extent).

There are also code bloating sources persisting from older versions:

1. Multiple zeroing of W register, like

Code: Select all

;ProcCmn.ppas,978 :: 			dTset:=2.0;
$7BBA	$0E00	    			MOVLW	0
$7BBC	$6FD1	    			MOVWF	_dtset, 1
$7BBE	$0E00	    			MOVLW	0
$7BC0	$6FD2	    			MOVWF	_dtset+1, 1
$7BC2	$0E00	    			MOVLW	0
$7BC4	$6FD3	    			MOVWF	_dtset+2, 1
$7BC6	$0E80	    			MOVLW	128
$7BC8	$6FD4	    			MOVWF	_dtset+3, 1
2. Bank switching just before RETURN or before MOVFF instruction.

3. SETF instruction is practically never used while it could replace two instructions operation, like

Code: Select all

	MOVLW	255
	MOVWF	STACK_0, 0

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

Re: ver 8.3 other code bloating sources

#2 Post by zristic » 14 Jul 2008 08:50

Thanks, janni.
For no.3, can you provide some code?

janni
Posts: 5373
Joined: 18 Feb 2006 13:17
Contact:

#3 Post by janni » 14 Jul 2008 15:07

If you meant the superflous movff instructions addition example, than it's simple:

Code: Select all

program test4;

var bb: byte;

begin
 bb:=Flash_Read($800);
end.
I've just realised where the superflous movff instructions come from - apparently the libraries supplied with v 8.3 were compiled with earlier version of the compiler - the one with Hi(longint) bug (flash libs' compilation date is 22.05.2008).

Post Reply

Return to “mikroPascal Beta Testing”