i cant understand some assigments such as:
= Assignment Binary right-to-left
+= -= *= /= Arithmetic assignment
%= &= ^= |= Arithmetic assignment
<<= >>= Arithmetic assignment
I am not pretty sure of what happen when you write:
count += 3;
it means that count is incrementing until it will be equal to 3?, if it's true, what happens when the assigment is for example *= or <<=.
I do really need some help with this, i'll highly appreciate it.
Assigments
-
- Member++
- Posts: 26
- Joined: Thu Nov 04, 2010 1:18 pm
-
- XCore Expert
- Posts: 956
- Joined: Fri Dec 11, 2009 3:53 am
- Location: Sweden, Eskilstuna
count += 3;
is
count = count+3;
In ANSI C it's possible to assign an operator that way.
To negate the value you can write:
count*=-1; e.g. count= -1 * count ;
Modulus:
count%=5; e.g. count = count%5;
It's even possible to write things as:
++count%=5;
is
count = count+3;
In ANSI C it's possible to assign an operator that way.
To negate the value you can write:
count*=-1; e.g. count= -1 * count ;
Modulus:
count%=5; e.g. count = count%5;
It's even possible to write things as:
++count%=5;
Probably not the most confused programmer anymore on the XCORE forum.
-
- XCore Expert
- Posts: 844
- Joined: Sun Jul 11, 2010 1:31 am
That's invalid, you're modifying the same object (namely count) more than oncelilltroll wrote:It's even possible to write things as:
++count%=5;
without intervening sequence point.
-
- Member++
- Posts: 26
- Joined: Thu Nov 04, 2010 1:18 pm
thank you.
now i have another question, what's the exactly mean of "@" in the code? I just know that you can only use @ with buffered ports.
for example in this case
I've read that in general is:
p @ t <: x
I bet that the value of "p" will change to "x" when "t" cycles of clock will have passed. However, I didnt get the following sintaxis
toggle <: 0 @ count
what does it mean?.
sorry for being noob..xD
now i have another question, what's the exactly mean of "@" in the code? I just know that you can only use @ with buffered ports.
for example in this case
Code: Select all
out buffered port:1 toggle = XS1_PORT_1B;
in port inClock = XS1_PORT_1C;
clock clk = XS1_CLKBLK_1;
int main(void) {
int count;
configure_clock_src(clk, inClock);
configure_out_port_no_ready(toggle, clk, 0);
start_clock(clk);
toggle <: 0 @ count; // read port counter
while (1) {
count += 3;
toggle @ count <: 1; // timed output
count += 2;
toggle @ count <: 0; // timed output
}
}
p @ t <: x
I bet that the value of "p" will change to "x" when "t" cycles of clock will have passed. However, I didnt get the following sintaxis
toggle <: 0 @ count
what does it mean?.
sorry for being noob..xD
-
- XCore Expert
- Posts: 754
- Joined: Thu Dec 10, 2009 6:56 pm
toggle <: 0 @ count
Each port has a 16-bit timer.
The time at which the value 0 is assigned to port toggle is stored in the variable count.
Each port has a 16-bit timer.
The time at which the value 0 is assigned to port toggle is stored in the variable count.
-
- Member++
- Posts: 22
- Joined: Sun Nov 07, 2010 6:33 pm
I like this onelilltroll wrote:It's even possible to write things as:
++count%=5;
u < 255 ?m[ u+1 ][v ]|=
4,m[u+1][ v]&48?W+1][v]&15]]):0:0;W][ v]& 15] ])
Courtesy of http://www.ioccc.org/main.html