S7: Accessing P-Area by means of a pointer

This is what i came up with. FC which takes a few arguments.

PAddr (Copy from addres)
Len (Number of characters to be copied)
DbNo (DB to copy to)
DbbNo (Offset within DB to copy to)

Code:
      L     DW#16#80000000              // P-Area
      L     #PAddr                      // P-Address to start copy from
      SLD   3                           // Byte.Bit orientation
      OD                                // Complete address
      LAR1                              // Store address in AR1
      L     #Db_No                      // Copy to DB
      T     #L_Db_No                    // Typecast to Word
      OPN   DB [#L_Db_No]               // Open DB
      L     P#1.0                       // Pointer 1 byte
      L     #Dbb_No                     // Startaddress, copy to
      *D                                // Pointer to startaddress
      LAR2                              // Store in AR2
      L     #Len                        // StrLen to copy
      T     DBB [AR2,P#0.0]             // String max len = Len
      T     DBB [AR2,P#1.0]             // String curr len = Len
      TAR2                              // AR2 -> ACCU
      L     P#2.0                       // Start of actual string
      +D                                // Calculate address
      LAR2                              // Store in AR2

      L     #Len                        // Prepare index
_001: T     #iLoopCnt                   // Store index counter
      L     B [AR1,P#0.0]               // Copy 1 char from P-Area
      T     DBB [AR2,P#0.0]             // Store 1 char in DB
      TAR1                              // Curr. copy from addr to ACCU
      L     P#1.0                       // Increase address
      +D                                // By 1
      LAR1                              // And store result in AR1
      TAR2                              // Curr. copy to address
      L     P#1.0                       // Increase address
      +D                                // By 1
      LAR2                              // And store result in AR2
      L     #iLoopCnt                   // Load index counter
      LOOP  _001                        // Loopa if greater than zero
 
Slimmer version:

Code:
      L     #PAddr                      // P-Address to start copy from
      SLD   3                           // Byte.Bit orientation
      LAR1                              // Store address in AR1
      L     #DB_No                      // Copy to DB
      T     #L_Db_No                    // Typecast to Word
      OPN   DB [#L_Db_No]               // Open DB
      L     #Dbb_No                     // Startaddress, copy to
      SLD   3                           // Pointer to startaddress
      LAR2                              // Store in AR2
      L     #Len                        // StrLen to copy
      T     DBB [AR2,P#0.0]             // String max len = Len
      T     DBB [AR2,P#1.0]             // String curr len = Len
_002: T     #iLoopCnt                   // Store index counter
      L     PIB [AR1,P#0.0]             // Copy 1 char from P-Area
      T     DBB [AR2,P#2.0]             // Store 1 char in DB
      +AR1  P#1.0                       // Increase address
      +AR2  P#1.0                       // Increase address
      L     #iLoopCnt                   // Load index counter
      LOOP  _002                        // Loopa if greater than zero
 

Similar Topics

Hi all, I am having issues accessing my Cimplicity software - the site code changed after re-install and I am no longer able to attain a new key...
Replies
10
Views
173
For the past few day, I have had problems accessing the Rockwell Knowledgebase. When I try to access it (and I do have a TechConnect Support...
Replies
7
Views
411
Hi, Small issue i've really been beating myself up over today. I've been working with Panelview panels for years. Currently working on an older...
Replies
1
Views
591
Dear experts, I have the following setup: CPU-313C (6ES7313-5BF03-0AB0 V2.6) + CP343-1 (6GK7343-1EX30-0XE0 V2.0) communicating with Siemens PC...
Replies
7
Views
2,708
I'm looking to replace an AB PanelView 600 2711-K6C2 HMI with a C-more EA9-T10WCL. The PLC in the system is a SLC 5/03, which is staying. I...
Replies
2
Views
1,249
Back
Top Bottom