Constant to variable copy fault

Beta Testing discussion on mikroBasic.
Post Reply
Author
Message
oliverb
Posts: 570
Joined: 24 May 2007 15:09

Constant to variable copy fault

#1 Post by oliverb » 02 Jan 2009 18:47

I haven't made a minimal code sample yet but if I declare a constant array containing 10 words and then write it to a variable then the generated code only copies the first 5 words of the array, basically it is copying the equivalent number of bytes.

Apologies for the messy code extract...

Code: Select all

const optiondefault as word[optioncount] =
    (0,0,0,50,1, 0,1,0,1,0)
dim optionvals as word[optioncount]



implements
dim aa,bb as byte
dim temp as byte
sub procedure default_config
  optionvals=optiondefault
end sub
Looking at the disassembly we find that only 10 bytes are copied not 10 words.

Code: Select all

;fpa084options.pbas,65 :: 			optionvals=optiondefault
$2C32	$0E42	    			MOVLW	#_optiondefault
$2C34	$6EF6	    			MOVWF	TBLPTRL, 0
$2C36	$0E2F	    			MOVLW	@#_optiondefault
$2C38	$6EF7	    			MOVWF	TBLPTRH, 0
$2C3A	$0E00	    			MOVLW	@@#_optiondefault
$2C3C	$6EF8	    			MOVWF	TBLPTRU, 0
$2C3E	$0E38	    			MOVLW	_optionvals
$2C40	$6EE1	    			MOVWF	FSR1L, 0
$2C42	$0E00	    			MOVLW	@_optionvals
$2C44	$6EE2	    			MOVWF	FSR1H, 0
$2C46	$0E0A	    			MOVLW	10
$2C48	$	L_default_config_0:
$2C48	$0009	    			TBLRD*+
$2C4A	$CFF5	FFE6			MOVFF	TABLAT, POSTINC1
$2C4E	$2EE8	    			DECFSZ	WREG, 1, 0
$2C50	$D7FB	    			BRA	L_default_config_0
$2C52	$	fpa084options_L_0:
$2C52	$0012	    			RETURN
$2D96	$	_toggle_rf_off:

User avatar
srdjan
mikroElektronika team
Posts: 1552
Joined: 28 Dec 2005 12:47
Location: Serbia

Re: Constant to variable copy fault

#2 Post by srdjan » 12 Jan 2009 15:42

Hi,
Could you, please, send me whole project folder to srdjan@mikroe.com.

oliverb
Posts: 570
Joined: 24 May 2007 15:09

#3 Post by oliverb » 12 Jan 2009 16:55

I'll have to make up a code sample for you. The program in question has since been edited to use a for-next loop instead of relying on a whole-array assignment.

User avatar
srdjan
mikroElektronika team
Posts: 1552
Joined: 28 Dec 2005 12:47
Location: Serbia

#4 Post by srdjan » 13 Jan 2009 13:08

Hi,
oliverb wrote:I'll have to make up a code sample for you. The program in question has since been edited to use a for-next loop instead of relying on a whole-array assignment.
We are working on a new pro version of the compiler as we speak. This
bug is already solved there.
Thank you for reporting this bug.

Post Reply

Return to “mikroBasic Beta Testing”