Thread: difference between ++ and +=1

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    Just an FYI,
    I read about the origin of "C", and how the compiler favored the reigning hardware platform of that time - PDP family of minis. So the post-increments and similar had a reason for being part of the language. There were native machine instructions of that ilk: access-then-increment. I haven't encountered any micro processors which had similar instructions but then again, the desired effect can be achieved with two instructions at most.

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by nonoob View Post
    Just an FYI,
    I read about the origin of "C", and how the compiler favored the reigning hardware platform of that time - PDP family of minis. So the post-increments and similar had a reason for being part of the language. There were native machine instructions of that ilk: access-then-increment. I haven't encountered any micro processors which had similar instructions but then again, the desired effect can be achieved with two instructions at most.
    Both VAX (32-bit version of PDP-11 really) and 68000 have post-increment and pre-decrement versions of it's instruction set. I'm fairly sure that ARM's instructions also matches the C language fairly well with it's STR/LDR instructions when setting the P and W bits to one of the instruction.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed