Chaipi Wijnbergen wrote: > > Dear PIC experts, > > I am using CCS PCM C compiler. I looked at the assembly that it generated > and did not understand something, maybe you can help me with it. > > When I wrote : > > i++; > > It compiled it into : > > movf i, W > incf i, F > > And when I wrote: > > i--; > > It compiled it into : > > movf i, W > decf i, F > > All instructions movf/decf/incf modify only the Z flag, so it can be used > the same way later as a test for branching, there is no extra information > on the status register supplied by the movf instructions, only W register > now holds the previus data of i, which was not used at all. > > Any idea why is the MOVF infront of incf/decf ? > > Thanks Chaipi > \\\|/// Perhaps, because you're doing "post-increment". So the compiler preserves the old value of the variable, in case you say : a = i++; in this case, the old value of "i" is stored in "a". Try, what happens, if you say "++i", i.e. "pre-increment" ? Does it generate a different sequence? It should! Wolfram +-----------------------------------------------+ ! Wolfram Liebchen, liebchen@ipserv.ffo.fgan.de ! ! Forschungsinstitut fuer Optik ! ! Schloss Kressbach ! ! D-72072 Tuebingen ! ! Tel: +49 (0)7071 / 709-158 ! ! Fax: +49 (0)7071 / 709-270 (G3 / G4) ! +-----------------------------------------------+