Subject:
|
Re: NQC preprocessor behavior - constants evaluated?
|
Newsgroups:
|
lugnet.robotics.rcx.nqc
|
Date:
|
Wed, 18 Aug 2004 20:25:17 GMT
|
Viewed:
|
5502 times
|
| |
| |
Code listing of Untitled1:
*** Var 47 = x
*** Var 46 = y
*** Task 0 = main
000 pwr ABC, 7 13 07 02 07
004 dir ABC, Fwd e1 87
006 setv var[47], 150 14 2f 02 96 00
011 setv var[46], 5 14 2e 02 05 00
016 mulv var[46], var[47] 54 2e 00 2f 00
Total size: 21 bytes
So it's basically doing this:
x = 150;
y = 5 * x;
(I have BricxCC 3.3 (build 3.3.7.5) and NQC 2.5. I really have to update
but I'm not using NQC often)
"Brian Davis" <brdavis@iusb.edu> escribió en el mensaje
news:I2InLL.yJw@lugnet.com...
> Pardon a basic, low-level question, but I'm trying to minimize memory &
> execution time. Does the NQC preprocessor precalculate constant expressions
> before the compile pass? For instance:
>
> #define CONST 100
> #define HALF CONST/2
>
> task main()
> {
> int x,y;
> x = 3 * HALF;
> y = 10 / 2 * x;
> }
>
> When this compiles, will the bytecode have the variable x assigned a single
> constant, or will the bytecode actually be doing time (and memory) wasting
> things like dividing 100 by 2 (in the second #define), or multipling a constant
> by another constant (the assignment statement). And could it take the second
> assignment statement and simplify it to a single math operation (5 * x).
> Anybody?
>
> --
> Brian Davis
|
|
Message is in Reply To:
| | NQC preprocessor behavior - constants evaluated?
|
| Pardon a basic, low-level question, but I'm trying to minimize memory & execution time. Does the NQC preprocessor precalculate constant expressions before the compile pass? For instance: #define CONST 100 #define HALF CONST/2 task main() { int x,y; (...) (20 years ago, 16-Aug-04, to lugnet.robotics.rcx.nqc)
|
3 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|