Substitutions for x = x + 1
Steel
Posts: 313
This is no big deal at all, but are there any substitutions for this command.
In assembly language, you can just do "inc x" which is much easier to type, and *may* take fewer clock pulses.
Anybody have any information on whether this is faster than x = x+1?
In assembly language, you can just do "inc x" which is much easier to type, and *may* take fewer clock pulses.
Anybody have any information on whether this is faster than x = x+1?
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
"SX-Video·Module" Now available from Parallax for only $28.95
http://www.parallax.com/detail.asp?product_id=30012
"SX-Video OSD module" Now available from Parallax for only·$49.95
http://www.parallax.com/detail.asp?product_id=30015
Product web site: www.sxvm.com
"If I was king for just one day...I don't think I could screw things up any worse [noparse];)[/noparse]"
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
So nope, it looks like X = X + 1 is the 'fastest' way to go about it.
FOR x=0 to final : NEXT
where of course the Stamp takes care of the x=x+1.
However, the FOR:NEXT construct on the Stamp is actually quite slow. I wouldn't swear to it, but I think the DO:LOOP construction is faster.
x=0 : DO : x=x+1 :LOOP UNTIL x=final
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Statements in BASIC like x = x + 1 or in C like x++, operate on a memory location associated (by the compiler) with the name "x". Translated into assembler it would actually become (at least) 3 instructions. Something like:
LOAD (address of x)
INCREMENT
STORE (address of x)
Post Edited (Bullwinkle) : 1/7/2006 10:40:55 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com