JOLTRON said:
So then is the P#0.0 and P#2.0 pointing to a specific part of the AR1???
LW[AR1,P#0.0]
LW[AR1, P#2.0]
And how would I go about having the pointer shift according to what part I have selected.
Part 1 db99.dbx20.0
part 2 db99.dbx40.0
part 3 db99.dbx60.0
etc....
I've gone thru quite a few other threads. the idea in my head is so simple it seems like alot of work to get it done.
thanks for your help so far.
AR1 is one of two address registers.
In the instruction
LAR1 #SOURCE
if SOURCE was the first TEMP declaration it would be in the first local flag area, i.e. Local Byte 0. As it has been declared as an ANY data type, it will take up 10 Bytes, so in total it will be local byte 0 to local byte 9.
local byte 0 = Step 7 format = w#16#10
local byte 1 = Data Format = w#16#01 = BIT, w#16#02 = BYTE, etc
local word 2 = Length
local word 4 = Data Block number (0 if not a DB)
local byte 6 = Data Type = w#16#83 = Marker flag, w#16#84 = DB data, etc
local byte 7 and local word 8 = BYTE,BIT address.
The T LW[AR1,P#x.0]instruction is filling these words and bytes to point to your DB, DW address. As AR1 was loaded with the starting point of the parameter SOURCE, it is pointing to L 0.0, the P# part is offsetting from the address AR1 pointes to, where P#x.y where x=byte and y=bit.
To point to a different area, for example to change to db99.dbx40.0, you would repeat the part
L 6 // In this example it is DW6
SLD 3 // The 3 right most bits of Byte 9 make up the bit address (0-7)
T LD[AR1, P#6.0] // Byte address is in Bytes 7, 8 and 9
L B#16#84 // 84=Data Area (see help to find other areas, like flags etc)
T LB[AR1, P#6.0] // Byte 6 = data type
but change 6 to 40.
For a block move, you would set up two TEMP ANY parameters, one for the source address and one for the destination address. When using SFC20, these cannot cross.
In the past I have used SFC20 to control a shift register, I had to call it twice, the first to move from source to a temporary store area, the second to move it from the temp store to the destination as the source and destinations overlapped.