Announcement

Collapse
No announcement yet.

i += 4 == INCR i BY 4

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • i += 4 == INCR i BY 4

    Hello,

    Can anyone suggest a way to add a value to a variable that is as efficient as the C++ statement of i += 4?

    I know there is the INCR statement that will add a value of one to the variable, but it does not allow for any other values.

    The reason for this is:

    i = i + 4 in C++ takes the value of the memory at i and copies it to the accumulator, then adds the 4 to it, then copies the new value back to the memory at i.

    In i += 4, the code simply adds 4 to the memory location at the location i. Thus there is no double copying of the values.

    I guess what I’m looking for or would like is the command INCR I BY 4

    Thanks,

    -------------
    Colin Schmidt & James Duffy, Praxis Enterprises, Canada

  • #2
    Hi
    For LONG and DWORD!
    'dim i as long

    ! add i,4

    or

    ! mov eax,i
    ! add eax,4
    ...
    or
    ! inc i
    ! inc i
    ! inc i
    ! inc i
    -------------------------------
    V.Shualkov
    Spherical Panorama Inc. Virtual Reality for: Real Estate, Tourism Advertisment.

    Comment


    • #3
      In PB Dos 3.x you could specify:

      Incr i,4

      Love to see that added to the PB/DLL and PB/CC...

      Scott

      -------------
      Scott Turchin


      Scott Turchin
      MCSE, MCP+I
      http://www.tngbbs.com
      ----------------------
      True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

      Comment


      • #4
        Vladimir Shulakov: Thanks! "! add i, 4" is exactly what I was looking for.

        Scott Turchin: I'm assumming the reason they don't have inc i, 4 is because of the above. Although if it is as simple to add to the compiler as I think it might be, then I'd say YES!

        Thanks,

        -------------
        Colin Schmidt & James Duffy, Praxis Enterprises, Canada


        [This message has been edited by Colin Schmidt (edited January 21, 2000).]

        Comment

        Working...
        X