News:

  • June 13, 2026, 03:43:15 AM

Login with username, password and session length

Author Topic: Indexing Data Locations  (Read 10594 times)

Tired_Old_Man

  • Newbie
  • *
  • Posts: 9
Indexing Data Locations
« on: November 08, 2014, 09:01:21 PM »
Good evening. I am trying to load an ascii string into a register (v10000) that will be 7 words long (14 ascii characters) and then index a pointer to the next v register that is 8 words away. Sorry, my eyes are blurring... I would like to load the first value into V10000, the next into V10010, the next into V10020, v10030, ect... I have been unsuccessful thus far and feel I am repeating the same mistakes... Any help would be appreciated. Also, if anyone know how to search for ascii strings in tables I would be extremely grateful. Thank you all.

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: Indexing Data Locations
« Reply #1 on: November 08, 2014, 10:31:33 PM »
Which PLC?

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3607
  • Darth Ladder
Re: Indexing Data Locations
« Reply #2 on: November 08, 2014, 10:34:37 PM »
Sounds like you're using a DL-classic processor, so the following advice will apply to that scenario.

First of all, remember that memory addresses are in octal.  There are two approaches to dealing with this.  You can specify in octal, using LDA, or you can do your pointer arithmetic in decimal (not BCD), but then you'll have to figure out what the corresponding decimal values are.  (The Analysis Toolpak in Excel has DEC2OCT and OCT2DEC functions, and I use an Android app called Hex Plus) o10000, for example, is 4096 decimal, and your offset of o10 will be 8 in decimal.  So if you want to index the first one zero, then the expression to calculate the address for the first register of the nth string will be 4096 + 8n.  If you want the first one to correlate to an index of 1, then use 4088 + 8n.  You have to use MATHBIN, or use the binary versions of individual math boxes.  Take the result and put it in a register, say V7700, then when using it as a pointer, use "P" notation, as in P7700.  That means "the register whose address is stored in decimal form, in V7700".

If it's Do-More, then V's are decimal indexed, and can also use array notation, as in V[V9999], where V9999 is the calculated pointer value.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

Tired_Old_Man

  • Newbie
  • *
  • Posts: 9
Re: Indexing Data Locations
« Reply #3 on: November 09, 2014, 09:00:43 AM »
Thank you both, I'm sorry, I was getting a little loopy and decided sleep might help. I am using a D06 and was trying to load a constant K8 (octal 10) and add to my pointer register and index my pointer so that it would go 10000, 10010, 10020...Thanks PLCGUY, I just tried 8 consecutive ADDB and it worked, I didn't even think of that and hoped there was a different way although not much could be easier. Perhaps this is my day and I can close this out :-) Have you ever used a find function to look through a table for ascii? I am going to store ~500 barcodes (each 14 characters) and I want to compare each new scan to the existing ones to make sure there are no duplicates? As always the help is appreciated!!!!

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3607
  • Darth Ladder
Re: Indexing Data Locations
« Reply #4 on: November 09, 2014, 10:24:25 AM »
You're welcome!  No, I don't believe I've ever done an ASCII table search in a DL PLC.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.