Forum Index
HomeZBasic Home   Forum RulesForum Rules   Forum FAQForum FAQ   MemberlistMemberlist   UsergroupsUsergroups   RSS FeedRSS Feed
Site SearchSite Search   LinksLinks   DownloadDownload   Digests and SubscriptionsDigests and Subscriptions
ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in   RegisterRegister
Possible MID function error

 
Post new topic   Reply to topic    Forum Index -> ZBasic Language
Author Message
cloxwerx



Joined: 01 Dec 2005
Posts: 37
Location: Tucson, Arizona

Posted: 08 February 2006, 23:09 PM    Post subject: Possible MID function error Reply with quote

The following code indicates that variable, DummySpacer, which should not be changed, is changed. The long beep indicating this occurs in my test system. I ran some For statements to step the MID index and the MID length and the glitch occured for a position of 6 and lengths of 1 through 5. If the first Delay statement is commented out, there is no glitch.

Code:
Option   Explicit

'
'   Demonstrate MID left side function glitch
'
Public Const FreqOutPin     As Byte = 15    'Pin for Tone out

Public Wka (1 To 15)        As Byte         'TNC/GPS input work area
Public OtherCall            As String * 9   'Others CALLSIGN+SSID
Public DummySpacer          As Byte         'In case of erroneous string overflow
Public TNCInQue (1 To 50)   As Byte         'I/O queues
Public ii                   As Byte         'Loop counter
Public jj                   As Byte         'Loop counter

Public Sub Main ()
OtherCall="         "                       '9 spaces
DummySpacer=100                             'Just some initial value

Call Delay (0.5)
Wka(3)=6
Wka(4)=1
Mid(OtherCall,Wka(3),Wka(4))="     "        'Pad with up to five spaces
      
If DummySpacer <> 100 Then                  'Did it remain untouched?
   Call FreqOut(FreqOutPin,3900,3908,3000) 'No, Send a long beep
   Call Delay (1.0)
End If

End Sub



IDE V 1.0.3
ZX-24 firmware version 1.1.2

This one kept me awake for a while trying to discover what was happening in a 1500 line program.

Dennis
Back to top
mikep



Joined: 24 Sep 2005
Posts: 765
Location: Austin, TX

Posted: 09 February 2006, 0:14 AM    Post subject: Reply with quote

I'm sure Don is looking into this problem right now.

My guess is that you have found a compiler optimization problem whereby it generates the wrong code. These are unfortunate and hard to isolate. To prove it you can turn off compiler optimization by adding the following line to the top of your PRJ file:
Code:
–-optimize=no-optimize
Back to top
cloxwerx



Joined: 01 Dec 2005
Posts: 37
Location: Tucson, Arizona

Posted: 09 February 2006, 1:08 AM    Post subject: Reply with quote

Mike,

Thanks, that would be a good starting point except that optimization has been off in the larger program since the "early days". Though optimization was not off in the smaller test example, I just tried it and no change, so maybe this will be a bit easier to solve.

Dennis
Back to top
dkinzer
Site Admin


Joined: 03 Sep 2005
Posts: 2493
Location: Portland, OR

Posted: 09 February 2006, 2:21 AM    Post subject: Reply with quote

Quote:
If the first Delay statement is commented out, there is no glitch.

I was able to reproduce the problem but it still manifested with the delay commented out. In both cases, I compiled with optimization off.

It turns out that it is not an optimization problem. Rather it is an error in the VM code. The problem is caused by an incorrect comparison in the code that computes the number of characters that should be modified. As stated in the manual, the number of characters affected is supposed to be the minimum of:

1) the number of characters in the string from the specified position (second parameter) through the end of the string

2) the number of characters specified by the third parameter

3) the number of characters in the replacement string (the right hand side of the assignment).

The solution was simple and very localized. I'll post a new version of the VM after the regression tests (updated to check for this problem) are run. In the interim, if you'd like to begin using v1.1.3 while it is being tested you can retrieve the update image using the links below.

ZX-24
ZX-40
ZX-44

Thank you, Dennis, for taking the time to produce a succinct test case that demonstrated the problem.

Quote:
...optimization has been off in the larger program since the "early days".

I would encourage you to use the default optimization. There are no known optimization problems at present. There has been only one optimization problem discovered since the offical public release and it was fixed in the v1.1.0 release (mid December).
Back to top
cloxwerx



Joined: 01 Dec 2005
Posts: 37
Location: Tucson, Arizona

Posted: 09 February 2006, 6:02 AM    Post subject: Reply with quote

You're welcome, Don. There's a perverse sense of accomplishment in discovering glitches in a well put together system. Glad I can contribute in a small way to the ZBasic robustness.

I'll have to turn on optimization after your statement of confidence in it. If there's a problem it has a good chance of showing up in this program.

Dennis
Back to top
mikep



Joined: 24 Sep 2005
Posts: 765
Location: Austin, TX

Posted: 09 February 2006, 6:08 AM    Post subject: Reply with quote

cloxwerx wrote:
There's a perverse sense of accomplishment in discovering glitches in a well put together system. Glad I can contribute in a small way to the ZBasic robustness.
Well said Dennis.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> ZBasic Language Time synchro. with the server - Timezone/DST with your computer
Page 1 of 1

 


All content Copyright © 2005-2012 Elba Corp. All Rights Reserved.
Opinions expressed in posts are those of the author and not necessarily those of Elba Corp.
Powered by phpBB © 2001, 2005 phpBB Group