flatten float cause NXT block frozon

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
Post Reply
felix2ch
Posts: 33
Joined: 11 Jun 2013, 16:46

flatten float cause NXT block frozon

Post by felix2ch »

Code: Select all

task main(){
     long val = 1000;
     string sval;
     sval = FlattenVar(val);

     TextOut(0, LCD_LINE1, NumToStr(sval[0]));
     TextOut(0, LCD_LINE2, NumToStr(sval[1]));
     TextOut(0, LCD_LINE3, NumToStr(sval[2]));
     TextOut(0, LCD_LINE4, NumToStr(sval[3]));

     while(1);
}
Every thing is ok.

But Nxt will be frozen when replace "long var" with "float var".
After change the optimization level to 1 from 2, the "float var" code run correctly.

Is it a optimization Bug?
afanofosc
Site Admin
Posts: 1256
Joined: 26 Sep 2010, 19:36
Location: Nashville, TN
Contact:

Re: flatten float cause NXT block frozon

Post by afanofosc »

Can you post the F12 code listing with level 1 and level 2 optimization set. I think you may have an older compiler. It would help to know exactly what version of NBC or BricxCC you are running (see Help About or the output of typing "nbc" from a command prompt).

John Hansen
Multi-platform LEGO MINDSTORMS programming
http://bricxcc.sourceforge.net/
felix2ch
Posts: 33
Joined: 11 Jun 2013, 16:46

Re: flatten float cause NXT block frozon

Post by felix2ch »

Thanks for your help. :)
bricxCC Version3.3 build3.3.8.9
Next Byte Codes Compiler version 1.2 (1.2.1.r4,

Optimization level 2:

Code: Select all

dseg	segment
;------- definitions -------
Location_def	struct
X	sword
Y	sword
Location_def	ends
__TextOutArgs_def	struct
Result	sbyte
Location	Location_def	
Text	byte[]
Options	dword
__TextOutArgs_def	ends
;------- declarations -------
__DU0main	dword	
__signed_stack_001main	sdword	
__main_7qG2_val_7qG2_000	sdword	
__D0main	sdword	
__signed_stack_003main	sdword	
__signed_stack_002main	sdword	
____initialize_global_data_return	byte	
__ArrHelper__main_98_0	byte	
__PFTmp	byte	
__zfmain	byte	
__TextOutArgs	__TextOutArgs_def	
__main_7qG2_sval_7qG2_000	byte[]	
__strbufmain	byte[]	
__strretvalmain	byte[]	
dseg	ends
;------- code -------
thread main
	subcall __initialize_global_data, ____initialize_global_data_return
	set __main_7qG2_val_7qG2_000, 1000
	flatten __strretvalmain, __main_7qG2_val_7qG2_000
	strcat __strbufmain, __strretvalmain
	mov __main_7qG2_sval_7qG2_000, __strbufmain
	set __signed_stack_001main, 0
	set __signed_stack_002main, 56
	set __signed_stack_003main, 0
	index __ArrHelper__main_98_0, __main_7qG2_sval_7qG2_000, __signed_stack_003main
	mov __DU0main, __ArrHelper__main_98_0
	numtostr __strretvalmain, __DU0main
	strcat __strbufmain, __strretvalmain
	mov __TextOutArgs.Location.X, __signed_stack_001main
	mov __TextOutArgs.Location.Y, __signed_stack_002main
	set __TextOutArgs.Options, 0
	mov __TextOutArgs.Text, __strbufmain
	syscall 13, __TextOutArgs
	set __signed_stack_001main, 0
	set __signed_stack_002main, 48
	set __signed_stack_003main, 1
	index __ArrHelper__main_98_0, __main_7qG2_sval_7qG2_000, __signed_stack_003main
	mov __DU0main, __ArrHelper__main_98_0
	numtostr __strretvalmain, __DU0main
	strcat __strbufmain, __strretvalmain
	mov __TextOutArgs.Location.X, __signed_stack_001main
	mov __TextOutArgs.Location.Y, __signed_stack_002main
	set __TextOutArgs.Options, 0
	mov __TextOutArgs.Text, __strbufmain
	syscall 13, __TextOutArgs
	set __signed_stack_001main, 0
	set __signed_stack_002main, 40
	set __signed_stack_003main, 2
	index __ArrHelper__main_98_0, __main_7qG2_sval_7qG2_000, __signed_stack_003main
	mov __DU0main, __ArrHelper__main_98_0
	numtostr __strretvalmain, __DU0main
	strcat __strbufmain, __strretvalmain
	mov __TextOutArgs.Location.X, __signed_stack_001main
	mov __TextOutArgs.Location.Y, __signed_stack_002main
	set __TextOutArgs.Options, 0
	mov __TextOutArgs.Text, __strbufmain
	syscall 13, __TextOutArgs
	set __signed_stack_001main, 0
	set __signed_stack_002main, 32
	set __signed_stack_003main, 3
	index __ArrHelper__main_98_0, __main_7qG2_sval_7qG2_000, __signed_stack_003main
	mov __DU0main, __ArrHelper__main_98_0
	numtostr __strretvalmain, __DU0main
	strcat __strbufmain, __strretvalmain
	mov __TextOutArgs.Location.X, __signed_stack_001main
	mov __TextOutArgs.Location.Y, __signed_stack_002main
	set __TextOutArgs.Options, 0
	mov __TextOutArgs.Text, __strbufmain
	syscall 13, __TextOutArgs
	mov __D0main, __TextOutArgs.Result
__NXC_Label_523:
	set __D0main, 1
	tst 5, __zfmain, __D0main
	brtst 4, __NXC_Label_524, __zfmain
	jmp __NXC_Label_523
__NXC_Label_524:
	exit -1, -1
endt
;------------------------
subroutine __initialize_global_data
	subret ____initialize_global_data_return
ends
;------------------------
Level 1:

Code: Select all

dseg	segment
;------- definitions -------
Location_def	struct
X	sword
Y	sword
Location_def	ends
__TextOutArgs_def	struct
Result	sbyte
Location	Location_def	
Text	byte[]
Options	dword
__TextOutArgs_def	ends
;------- declarations -------
__signed_stack_001main	sdword	
__D0main	sdword	
__DU0main	dword	
__signed_stack_002main	sdword	
__main_7qG2_val_7qG2_000	sdword	
__signed_stack_003main	sdword	
__constVal256	sword	256
____initialize_global_data_return	byte	
__zfmain	byte	
__PFTmp	byte	
__constVal0	sbyte	
__ArrHelper__main_98_0	byte	
__TextOutArgs	__TextOutArgs_def	
__strbufmain	byte[]	
__main_7qG2_sval_7qG2_000	byte[]	
__GraphicOutEmptyVars	sdword[]	
__strretvalmain	byte[]	
dseg	ends
;------- code -------
thread main
	subcall __initialize_global_data, ____initialize_global_data_return
	arrinit __GraphicOutEmptyVars, __constVal0, __constVal256
	set __D0main, 1000
	mov __main_7qG2_val_7qG2_000, __D0main
	flatten __strretvalmain, __main_7qG2_val_7qG2_000
	strcat __strbufmain, __strretvalmain
	mov __main_7qG2_sval_7qG2_000, __strbufmain
	set __D0main, 0
	mov __signed_stack_001main, __D0main
	set __D0main, 56
	mov __signed_stack_002main, __D0main
	set __D0main, 0
	mov __signed_stack_003main, __D0main
	index __ArrHelper__main_98_0, __main_7qG2_sval_7qG2_000, __signed_stack_003main
	mov __DU0main, __ArrHelper__main_98_0
	numtostr __strretvalmain, __DU0main
	strcat __strbufmain, __strretvalmain
	mov __TextOutArgs.Location.X, __signed_stack_001main
	mov __TextOutArgs.Location.Y, __signed_stack_002main
	set __TextOutArgs.Options, 0
	mov __TextOutArgs.Text, __strbufmain
	syscall 13, __TextOutArgs
	mov __D0main, __TextOutArgs.Result
	set __D0main, 0
	mov __signed_stack_001main, __D0main
	set __D0main, 48
	mov __signed_stack_002main, __D0main
	set __D0main, 1
	mov __signed_stack_003main, __D0main
	index __ArrHelper__main_98_0, __main_7qG2_sval_7qG2_000, __signed_stack_003main
	mov __DU0main, __ArrHelper__main_98_0
	numtostr __strretvalmain, __DU0main
	strcat __strbufmain, __strretvalmain
	mov __TextOutArgs.Location.X, __signed_stack_001main
	mov __TextOutArgs.Location.Y, __signed_stack_002main
	set __TextOutArgs.Options, 0
	mov __TextOutArgs.Text, __strbufmain
	syscall 13, __TextOutArgs
	mov __D0main, __TextOutArgs.Result
	set __D0main, 0
	mov __signed_stack_001main, __D0main
	set __D0main, 40
	mov __signed_stack_002main, __D0main
	set __D0main, 2
	mov __signed_stack_003main, __D0main
	index __ArrHelper__main_98_0, __main_7qG2_sval_7qG2_000, __signed_stack_003main
	mov __DU0main, __ArrHelper__main_98_0
	numtostr __strretvalmain, __DU0main
	strcat __strbufmain, __strretvalmain
	mov __TextOutArgs.Location.X, __signed_stack_001main
	mov __TextOutArgs.Location.Y, __signed_stack_002main
	set __TextOutArgs.Options, 0
	mov __TextOutArgs.Text, __strbufmain
	syscall 13, __TextOutArgs
	mov __D0main, __TextOutArgs.Result
	set __D0main, 0
	mov __signed_stack_001main, __D0main
	set __D0main, 32
	mov __signed_stack_002main, __D0main
	set __D0main, 3
	mov __signed_stack_003main, __D0main
	index __ArrHelper__main_98_0, __main_7qG2_sval_7qG2_000, __signed_stack_003main
	mov __DU0main, __ArrHelper__main_98_0
	numtostr __strretvalmain, __DU0main
	strcat __strbufmain, __strretvalmain
	mov __TextOutArgs.Location.X, __signed_stack_001main
	mov __TextOutArgs.Location.Y, __signed_stack_002main
	set __TextOutArgs.Options, 0
	mov __TextOutArgs.Text, __strbufmain
	syscall 13, __TextOutArgs
	mov __D0main, __TextOutArgs.Result
__NXC_Label_523:
	set __D0main, 1
	tst 5, __zfmain, __D0main
	brtst 4, __NXC_Label_524, __zfmain
	jmp __NXC_Label_523
__NXC_Label_524:
	exit -1, -1
endt
;------------------------
subroutine __initialize_global_data
	subret ____initialize_global_data_return
ends
;------------------------
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: flatten float cause NXT block frozon

Post by HaWe »

hey, that's a very old release!
Better look here:
http://sourceforge.net/apps/phpbb/mindb ... e2a1147701
felix2ch
Posts: 33
Joined: 11 Jun 2013, 16:46

Re: flatten float cause NXT block frozon

Post by felix2ch »

doc-helmut wrote:hey, that's a very old release!
Better look here:
http://sourceforge.net/apps/phpbb/mindb ... e2a1147701
Download the test_release20130813, And the problem is gone!
Thanks! :D
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests