To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.nqcOpen lugnet.robotics.rcx.nqc in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / NQC / 1773
1772  |  1774
Subject: 
Re: Blocking SetUserDisplay?
Newsgroups: 
lugnet.robotics.rcx.nqc
Date: 
Sun, 5 Jun 2005 20:57:53 GMT
Viewed: 
10923 times
  
In lugnet.robotics.rcx.nqc, John Hansen wrote:
> In lugnet.robotics.rcx.nqc, Ross Crawford wrote:
> > I can work around it by doing:
> > 
> > b = x * 100 + y;
> > a = b;
> > 
> > but I was wondering if there's any other way to either force NQC to use
> > temporary space for calculations, or force the display routine to block until
> > the calculations are complete?
> 
> You may be able to work around this by using parenthesis (untested).
> 
> a = ((x * 100) + y);
> 
> or you might try
> 
> a = 0 + ((x * 100) + y);


Neither of these work, although the second one does introduce a temporary for
everything except for the 0 part.  It will result in the display sometimes
showing a value of zero.

NQC tries really hard to use as few variables as it can so you need to
explicitly use a different variable to store the intermediate calculations.
Here is a convoluted way that works:

a = a + (x * 100 + y) - a;

012 setv       var[47], var[0]       14 2f 00 00 00
017 setv       var[46], var[1]       14 2e 00 01 00
022 mulv       var[46], 100          54 2e 02 64 00
027 sumv       var[46], var[2]       24 2e 00 02 00
032 sumv       var[47], var[46]      24 2f 00 2e 00
037 subv       var[47], var[0]       34 2f 00 00 00
042 setv       var[0], var[47]       14 00 00 2f 00

It's more efficient to define a local variable like you are doing:

int b = x * 100 + y;
a = b;

012 setv       var[47], var[1]       14 2f 00 01 00
017 mulv       var[47], 100          54 2f 02 64 00
022 sumv       var[47], var[2]       24 2f 00 02 00
027 setv       var[0], var[47]       14 00 00 2f 00


John Hansen



Message is in Reply To:
  Re: Blocking SetUserDisplay?
 
(...) You may be able to work around this by using parenthesis (untested). a = ((x * 100) + y); or you might try a = 0 + ((x * 100) + y); John Hansen (URL) (21 years ago, 5-Jun-05, to lugnet.robotics.rcx.nqc)

6 Messages in This Thread:




Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR