Sign in to follow this  
Followers 0
Gedeon

OPN DB - where to use?

2 posts in this topic

Hi, I've tried to get values from array which is a part of some DB. I've created a loop. I've opened DB using "OPN DB1000" (1st line) and I thought that it's all what it necessary to use DB pointers inside DB1000. But when I add the loop, it hasn't worked. Pointers in procedure after jump to the label didn't see that DB has been opened and I had to open it once again after the label (11th line). Why did I have to do that again? What's the general rule of using OPN with DB pointers? thanks for help or advice, Luke OPN DB1000 // open DB L P#DBX 90.0 // first byte of table T MD 3020 L 0 T MD 3010 L 5 jump: T MW 3000 OPN DB1000 L MD 3020 LAR1 L D [AR1,P#0.0] T MD 3010 // modify pointer TAR1 L P#4.0 //offset 4B +AR1 TAR1 MD 3020 L MW 3000 LOOP jump MW 3000 - loop counter MD 3010 - value from DB MD 3020 - pointer storage

Share this post


Link to post
Share on other sites
Seems a lot of unnecessary code there. How I would do it. L P#DBX 90.0 // first byte of table, don't need to open the DB to put pointer into AR1, shouldn't need MD3020 as AR1 keeps the pointer LAR1 // also no need to zero MD3010 as you will write into it. OPN DB1000 // If your not changing DB's then opening more than once should not be necessary L 5 jump: T MW 3000 L D [AR1,P#0.0] // Maybe L DBD [AR1,P#0.0] but DBX in the load AR1 should be suffice to indicate a Dataword T MD 3010 // modify pointer L P#4.0 //offset 4B, no need for the TIR's +AR1 L MW 3000 LOOP jump check the status online to see the DB active, it must be enabled in the right hand status column, this should tell you what DB is open, it should still be the last one opened. The other thing, this loops around 5 times overwriting MD 3010, so Md 3010 will contain the last transfer only. I'd also use TEMP memory for the loop. Edited by Groo

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0