Explain the use of the word constant in a line of code
Don M
Posts: 1,653
What is the difference between this:
i2c.ReadLong(i2c#BOOTPIN, EE_DEVICE_ADDR, constant(EE_BASE_ADDR + $0))
and this:
i2c.ReadLong(i2c#BOOTPIN, EE_DEVICE_ADDR, EE_BASE_ADDR)
What does "constant" do along with the "+ $0" ?
BTW I did read the Propeller manual pages 91 & 92 but I don't quite understand it.
Thanks.
Don
i2c.ReadLong(i2c#BOOTPIN, EE_DEVICE_ADDR, constant(EE_BASE_ADDR + $0))
and this:
i2c.ReadLong(i2c#BOOTPIN, EE_DEVICE_ADDR, EE_BASE_ADDR)
What does "constant" do along with the "+ $0" ?
BTW I did read the Propeller manual pages 91 & 92 but I don't quite understand it.
Thanks.
Don
Comments
When it makes a difference is if you add a number other then $0.
For example, assume EE_BASE_ADDR has a value of $1000:
Will do the addition EE_BASE_ADDR + $4 at compile time passing $1004 at run time.
While
Will do the addition at runtime (on the propeller). In other words the second one will be slightly larger and slightly slower.
Hope this helps
Jay