Pointer Format

manmeetvirdi

Member
Join Date
Oct 2004
Location
India.
Posts
750
OK if code is ...


LAR1 P#M 0.0
L N
SLD Y
+AR1


Now AR1 is pointing to byte Nx2^(Y-3) of M address area.
Maximum possible value of Y is 14, and the minimum value is 3.Because if less then 3 then it comes to bit area of the pointer.
Question is why the maximum value of Y is 14 (when N=1), it should be 15.



:oops:

Pointer.JPG
 
Pointer address is a DWORD, 32 bits.

The DWORD is made up of

aaaa aaaa xxxx xwww wwww wwww wbbb

a= memory area
x= unused
w= word address
b= bit address
 
Hello PeterW

Actually was concerned with Byte 4 and 5 of the pointer .

If N=1 and we do SLD14 then bit reaches up to 14th bit of Word (and points to 2048th byte) and one bit is vacant still.May the attached picture explains the best

pointer1.JPG
 
Pointer address is a DWORD, 32 bits.

The DWORD is made up of

aaaa aaaa xxxx xwww wwww wwww wbbb

a= memory area
x= unused
w= word address
b= bit address


Miscounted the number of bits I put in

aaaa aaaa xxxx xwww wwww wwww wwww wbbb

is the actual.

Why is the maximum value 14?

The pointer is a double word (32 bits) not 16, you can place a 1 then SLD3 to get the least bit of the word address or SLD18 to the highest bit of the word address.

So I'm unsure why you say 14 is the max.

18 is the max, the pointer is 32 bits not 16.

Of course you are limited by the size of the start number.
 
The +AR1 instruction is the limitation - see help as below

Description

+AR1 (add to AR1) adds an offset specified either in the statement or in ACCU 1-L to the contents of AR1. The integer (16 bit) is initially expanded to 24 bits with its correct sign and then added to the least significant 24 bits of AR1 (part of the relative address in AR1). The part of the area ID in AR1 (bits 24, 25, and 26) remains unchanged. The instruction is executed without regard to, and without affecting, the status bits.

+AR1: The integer (16 bit) to be added to the contents of AR1 is specified by the value in ACCU 1-L. Values from -32768 to +32767 are permissible.

+AR1 <P#Byte.Bit>: The offset to be added is specified by the <P#Byte.Bit> address.
 
So I'm unsure why you say 14 is the max.

18 is the max, the pointer is 32 bits not 16.

Ok PeterW I missed showing why I was saying 14 is the Max.
As per the picture with SLD15 it should point to 4096 but in actuality its different !!

LD read it, but dint got it......!!

pointer3.JPG
 
When you add to AR1 using the +AR1 instruction, the lower 16 bits of accu 1 are treated as a signed number. The maximum positive number you can represent in 16 bits is 7FFF = 32767 = P#4095.7

The +AR1 instruction allows you to specify negative numbers for the addition hence allowing you to index backwards through a table if you want to.

If you want to add a positive number greater than 7FFF = 32767 = P#4095.7 to AR1, you have to use the +D instruction. See example code below:

fc6007.jpg
 

Similar Topics

Hi All, in many library function of TiaPortal some data must be write using the pointer format........ eg.: P#DB90.DBX0.0 WORD 10 is it...
Replies
5
Views
2,817
Hello All, i would like to know details information about construct & Deconstruct requirement parameters of Pointer format in S7. Basically, my...
Replies
8
Views
3,995
Dear All, I'm new S7 user,my experience with S7 is very less,I tried to study many thread about SLD (Shift left DWORD) and Pointer in many forum...
Replies
2
Views
3,633
I use a lot of data organised as a struct in a db. Now I read in this struct as an in-parameter in a function. The in-parameter is specified as...
Replies
1
Views
4,235
Has anybody got a routine handy that will take an INT as input (1 - 21) and convert it to the Byte.Bit format that is needed to add to a basic...
Replies
14
Views
21,206
Back
Top Bottom