beautypg.com

Addr_ofs function, Ashr function, Ashr( a, n ) – Delta RMC151 User Manual

Page 360: Addr_ofs( loc , i )

background image

RMC70/150 and RMCTools User Manual

5.14.2.4. ADDR_OFS Function

ADDR_OFS(location, i)
Returns the address of the ith register after location. This function is intended only for use

with the COPY function.

Parameters

Location (Address)

The address of the register location.
i (DINT)

The offset, in 32-bit registers, from the location.

Return Value

Returns the address of the ith register after the register location. This address cannot be

used directly, but is intended to be passed into one of the COPY function’s parameters.

Remarks

The ADDR_OFS function can be used to calculate an address from a base address and an

offset when using the COPY function. For example, if the first tag in the block is called

MyFirstTag, then the address of a tag located 4 registers after MyFirstTag can be

calculated with:

ADDR_OFS(MyFirstTag, 4)

The ADDR_OF function is especially useful when copying from large blocks of data that

are not declared as arrays because it lends itself well to looping and calculating addresses

during each loop. However, best programming practice is usually to set up the data in

arrays, and use the COPY function on those arrays, which makes the ADDR_OFS

unnecessary.
The Address parameter may not be a local variable. Therefore, the ADDR_OFS function

may not be used in User Functions.

Examples

See the COPY function for an example.

5.14.2.5. ASHR Function

ASHR(a, n)
Shifts the bits in a to the right n times. The sign bit is shifted in on the left.

Parameters

a (DINT or DWORD)
The value to shift.
n (DINT)
The number of times to shift a. n must be between 0 and 31.

Return Value

Returns the same data type as a.

Remarks

The result of an invalid n is undefined.

340

Delta Computer Systems, Inc.

This manual is related to the following products: