BasicMicro - Forums

www.basicmicro.com
It is currently Sun May 20, 2012 10:56 pm

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 11 posts ] 
Author Message
 Post subject: Compiler Bug?
PostPosted: Tue Oct 20, 2009 4:53 pm 
Offline
Citizen

Joined: Sun Jul 05, 2009 12:01 pm
Posts: 12
Anyone have an idea why this code works:
repeat
debug [13, "Choose (Y or N):"]
debugin[MenuYesNo]
until MenuYesNO = "Y" or MenuYesNO = "N"
debug[13]
parenlevel = 0
parenlevel = 0
parenlevel = 0
parenlevel = 0

debug["start with:", menu(menuposition), ",", dec parenlevel, ",", hex parenlevel]

But if I remove three of the parenlevel = 0 's it does not set parenlevel to 0?

parenlevel is a word var

My guess compiler bug. I am running in debug.

Thanks, Tom

any hope of seeing an update to the IDE?

here is the whole thing:
'======================================================================
' Balloon with a menu System
'======================================================================

'=====Menu Variables
menui var word
menulevel var word
parenlevel var word
menuchoice var word
btn var byte
y var byte
ByteFrom var word
ByteTo var word
one con 1
i var long
Menu bytetable "(Menu(Setup#EEPROM(Init#Temp1((Yes(001))(No(099))))(init#Temp2((Yes(002))(No(099))))(Init#Alt((Yes)(003))(No(099))))(Setup#RTC((SetHour(004))(SetMin(005))))(Tests(Test#Servo((Up(006))(Down(007))))(Test#Heater((On(008))(Off(009)))(Test#Klaxon(010))(Test#RTC(011))(Test#Temp1(012))(Test#Temp2(013))))(Arm((Yes(014))(No(099)))))" ,0
'Menu bytetable "(Menu(Setup#EEPROM()Setup#RTC()Test#Heater()Arm()))" ,0
MenuStart var long
MenuPosition var Long
MenuYesNo var Byte
'======================================================================================================
' Main:
' Validate Menu and output to debug window
'
'======================================================================================================
Main:
'Gosub ValidateMenu
MenuStart = 5
gosub ProcessMenu
end
'======================================================================================================
' ValidateMenu:
' make sure it is a WFF
'======================================================================================================
ValidateMenu:
ByteFrom = 0
ByteTo = 0
ParenLevel = 0
repeat
if menu(ByteTo) = "(" then
debug [13]
for i = 0 to parenlevel
debug ["*"]
next
debug [ "[", dec parenlevel, "]"]
parenlevel = parenlevel + one
debug [menu(byteto)]
elseif menu(ByteTo) = ")"
debug [13]
for i = 0 to parenlevel - 1
debug ["*"]
next
debug [ "[", dec parenlevel, "]"]
parenlevel = parenlevel - one
debug [menu(byteto)]
else
debug [menu(byteto)]
endif
byteto = byteto + one
until parenlevel = 0 or menu(byteto) = 0
if menu(byteto) <> 0 then
debug[13,"Error: Not a WFF "]
if menu(byteto) >= 32 and menu(byteto) <= 126 then
debug[hex menu(byteto), " ", menu(byteto)]
else
debug[ hex menu(byteto)]
endif
debug[" at ",dec byteto]
endif
if (parenlevel = 0 and menu(byteto) = 0) then
debug[13,"WFF"]
endif
Return
'======================================================================================================
' ProcessMenu:
' It's a Tree
'======================================================================================================
ProcessMenu:
repeat

MenuPosition = MenuStart + 1
debug ["Menu Start:", dec menustart, ",", "MenuPosition:", dec menuposition]
if menu(menuposition) >= "0" and Menu(menuposition) <= "9" then
' what is the #
' do that number
' go up a level in the tree
else
Repeat
debug [13]
while menu(MenuPosition) <> "("
debug [menu(menuposition)]
menuposition = menuposition + 1
wend
debug [13,"wait for button"]
'debug[MenuPosition]
' if they choose it I I reset the menu start and fall thorugh a lot of below
MenuYesNO = " "
repeat
debug [13, "Choose (Y or N):"]
debugin[MenuYesNo]
until MenuYesNO = "Y" or MenuYesNO = "N"
debug[13]
parenlevel = 0
parenlevel = 0
parenlevel = 0
parenlevel = 0

debug["start with:", menu(menuposition), ",", dec parenlevel, ",", hex parenlevel]
repeat
debug [dec menuposition, ",",dec parenlevel,",", menu(menuposition)]
if menu(menuposition) = ")" then
parenlevel = parenlevel - 1
elseif menu(menuposition) = "("
parenlevel = parenlevel + 1
endif
menuposition = menuposition + 1
Until parenlevel = 0
'menuposition = menuposition + 1
Until menu(MenuPosition) = ")"
'menuposition = menuposition + 1
debug [13,"Done"]
MenuYesNO = " "
repeat
debug [13, "Choose (Y or N):"]
debugin [MenuYesNo]
until MenuYesNO = "Y" or MenuYesNO = "N"
debug [13]
' if they choose it go out one level
endif
until 1 = 2
return


Top
 Profile  
 
 Post subject: Re: Compiler Bug?
PostPosted: Tue Oct 20, 2009 5:14 pm 
Offline
Master

Joined: Sun Aug 17, 2008 5:26 pm
Posts: 798
Location: CA bay Area
Which compiler are you using?
If 2.2.11, it is no longer supported.
If Studio, which version? The latest is 1.0.0.14. If you aren't using this, download it, delete the old one using the Control Panel's Remove Software function, then install this. When done, try this again. If _14 is what you are using, good luck. It gives me a headache just to navigate all those parentheses. Please supply a brief description of how this works. And expect more questions after you answer the first one(s).

Anyone else?

Take care.

_________________
kenjj
http://blog.basicmicro.com/
http://kjennejohn.wordpress.com/


Top
 Profile  
 
 Post subject: Re: Compiler Bug?
PostPosted: Tue Oct 20, 2009 5:17 pm 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 527
I was about to ask some of the same questions. Like what is it that you think it is supposed to do? What it is doing? and what part of the code you have questions about?

Kurt


Top
 Profile  
 
 Post subject: Re: Compiler Bug?
PostPosted: Wed Oct 21, 2009 6:02 am 
Offline
Citizen

Joined: Sun Jul 05, 2009 12:01 pm
Posts: 12
1) I am using _14 of the studio

2) I have two places in my code where the intended assign target does not get set; I have shown one of them and how I solved that by setting it 4 times. The other is at the top of the repeat where it appears that the second time through the start position is not being set. There are two lines for setting the menu string one very simple and one more complex that for tsting can be interchanged by changing the comment.

3) This is the beginning of a menu processor (menus are trees, trees can be repd w/parens -> menus can be repd w/parens) and the validation tests for well formed formulas (WFF) or in this case WFF menus. Later, I will move the interface for display to the LCD display and the YN will be a a single button (pressed in a time frame -> yes, expired time -> no). It will be pretty amount of small code very sml use of pins (serout and one button). This code will become part of a high altitude ballon sensor and logging project. The sensor work is done and now I need a menu system.

4) Eventually I will use a VB program for graphically building the menu and generating the strings. The parens make my head spin too.

From the symptoms you might suspect that I am hosing my own variables with table references; although I reference tables none of them are for setting values just getting values.


Top
 Profile  
 
 Post subject: Re: Compiler Bug?
PostPosted: Wed Oct 21, 2009 7:01 am 
Offline
Citizen

Joined: Sun Jul 05, 2009 12:01 pm
Posts: 12
Support @ basicmicro:

1) I have uninstalled all BM s/w

2) I removed all registry entries for BM

3) I rebooted

4) Installed just Studio

5 I added this code:
parenlevel = 0
if parenlevel <> 0 then
debug ["OH Darm"]
debugin[MenuYesNO]

endif
6) It is still <> 0

7) I am stuck!

8) The code has be attached so a readable listing can be used


6) Is it the compiler? Is it my code? Is it the debugger? Help!!!!


Top
 Profile  
 
 Post subject: Re: Compiler Bug?
PostPosted: Wed Oct 21, 2009 4:05 pm 
Offline
Master

Joined: Sun Aug 17, 2008 5:26 pm
Posts: 798
Location: CA bay Area
Hi.
So, I modified your code-snippet to make it usable and came up with:
Code:
pl var byte
MYN var byte
pl = 0

main

IF pl <> 0 then
debug["Nuts!!"]
debugin[MYN]
endif
debug["pl is ", dec pl]
pl = pl + 1  ; make pl non-zero

goto main

I set up my Atom Lab Board with a Rev B (early version) Atom28-M module and programmed it using Atom2211 compiler. It ran OK. That is, on the first pass it fell thru to printing out pl's value, which was zero, then looped back to the top. Since pl had been incremented to "1", it failed the conditional and printed "Nuts". I hit a key and it printed "pl is 1", looped back, failed again, printed "Nuts!!", and so on. So far, so good.

I then installed a Rev D version of the Atom28 module. Since Atom2211 can't work with this, I had to program with Studio _14. Just as well, we have to go here eventually anyways. And it worked like above.

At this point I say: enter my code as it is written above and try it with your set up. By the way, what IS your set up? Which chip or module are you using, and which board are you using?

Take care.

_________________
kenjj
http://blog.basicmicro.com/
http://kjennejohn.wordpress.com/


Top
 Profile  
 
 Post subject: Re: Compiler Bug?
PostPosted: Wed Oct 21, 2009 4:54 pm 
Offline
Citizen

Joined: Sun Jul 05, 2009 12:01 pm
Posts: 12
Have you tried my code?

I am using a 28 pin Atom with the latest Studio.

There is a bug in two places and in both cases the variable gets hosed.


Top
 Profile  
 
 Post subject: Re: Compiler Bug?
PostPosted: Wed Oct 21, 2009 5:36 pm 
Offline
Master

Joined: Sun Aug 17, 2008 5:26 pm
Posts: 798
Location: CA bay Area
What rev is the Atom 28? B or D?
I might consider trying your code if you answer my earlier questions about what its for and how its supposed to work. Get back to me on that.
Take care.

_________________
kenjj
http://blog.basicmicro.com/
http://kjennejohn.wordpress.com/


Top
 Profile  
 
 Post subject: Re: Compiler Bug?
PostPosted: Wed Oct 21, 2009 6:11 pm 
Offline
Master

Joined: Tue Nov 21, 2006 9:34 am
Posts: 527
Sorry I can not try it. I only have one Atom and it won't work with studio. Studio hangs...

Kurt


Top
 Profile  
 
 Post subject: Re: Compiler Bug?
PostPosted: Wed Oct 21, 2009 7:00 pm 
Offline
Citizen

Joined: Sun Jul 05, 2009 12:01 pm
Posts: 12
What it is for and how it is supposed to work was posted at 3 PM today.


Top
 Profile  
 
 Post subject: Re: Compiler Bug?
PostPosted: Tue Oct 27, 2009 8:12 am 
Offline
Citizen

Joined: Sun Jul 05, 2009 12:01 pm
Posts: 12
The problem is related to the debug statements. The root cause is still being investigated by BM engineering. Nathan, thanks for your help.

I have sidestepped the issue by switching to serout and serin.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group

phpBB SEO