News:

  • June 26, 2026, 10:53:33 PM

Login with username, password and session length

Author Topic: CLeaning up a program by moving things  (Read 10120 times)

Garyhlucas

  • Hero Member
  • *****
  • Posts: 421
CLeaning up a program by moving things
« on: July 10, 2017, 11:55:50 AM »
As always seems to happens my good intentions about grouping bits, like alarms together in memory to make the program structure easier to understand often goes awry due to under estimating how many bits will be needed.  So I have now exceeded the 100 alarm bits I allowed for in a contiguous block.  Is there some easy way to move a bit or a word used in many places in the code to a new memory location?  I don't mind doing it one location at a time.  What I don't want is to totally trash an extensive program that is working well.

Thanks,

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3827
    • Host Engineering
Re: CLeaning up a program by moving things
« Reply #1 on: July 10, 2017, 12:03:50 PM »
Search->Replace
It will let you replace or swap a
  • single element
  • range of elements
  • list of single elements and/or ranges of elements

within the entire project or a specific code block, and how to move/merge any nicknames/extra info/description element documentation fields.

Make sure you are in Edit mode (Ctrl+E) to enable the Replace menu item.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3827
    • Host Engineering
Re: CLeaning up a program by moving things
« Reply #2 on: July 10, 2017, 12:06:02 PM »
One of the key features of Do-more is you can create a well-named block of bits called Alarm without the need for worrying about what your block of alarms bits in your C bit block is.

Allocate 96 of them to start, and if that isn't big enough later on, bump it by another 32 bits to 128, or 256 or whatever (it must be in blocks of 32 bits).  No need to change your code, just use Alarm0, Alarm42, Alarm95, etc.

Garyhlucas

  • Hero Member
  • *****
  • Posts: 421
Re: CLeaning up a program by moving things
« Reply #3 on: July 10, 2017, 01:16:46 PM »
Okay,
Both suggestions will make it easy for what I'd like to do.
Thanks,

Garyhlucas

  • Hero Member
  • *****
  • Posts: 421
Re: CLeaning up a program by moving things
« Reply #4 on: July 10, 2017, 04:01:35 PM »
Worked great!

Another question.  I have about 150 alarm bits all in the range of c1000-c1200.  Is there an easy way to tell if any bit in that range is set?

Thanks,

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6164
  • Yes Pinky, Do-more will control the world!
Re: CLeaning up a program by moving things
« Reply #5 on: July 10, 2017, 04:15:56 PM »
Worked great!

Another question.  I have about 150 alarm bits all in the range of c1000-c1200.  Is there an easy way to tell if any bit in that range is set?

Thanks,

The fastest way (execution wise) would be to do relational contacts on DWORD/WORD/BYTE casts, e.g., STRNEQ C992:D 0.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6164
  • Yes Pinky, Do-more will control the world!
Re: CLeaning up a program by moving things
« Reply #6 on: July 10, 2017, 04:22:27 PM »
Here's another option: MATH D0 = CountIfNE(0, C1000:B, 19)
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3827
    • Host Engineering
Re: CLeaning up a program by moving things
« Reply #7 on: July 10, 2017, 04:48:31 PM »
Since you start at C1000 (which is BYTE aligned), and end at C1999 (1000 bits is divisible by 8), you could write a subroutine AnyAlarmSet that sets a bit (nickname AlarmSet) based on if any bit is ON from C1000 thru C1999.

See the attached screenshot.