#Tell me about OS-9
10-Mar-89 01:09:00
Sb: #38096-#Tell me about OS-9
Fm: John Draper 76703,4322
To: Jeff Wilbourn 76657,2454
There is actually a very good reason for using -1 as the terminating
value in a DBcc. While it doesn't seem intuitive for some operations, the
main use of it is to count operations that manipulate data in a table.
Consider, if the termination was 0, you would not have to adjust the count,
but you would have to adjust the address of the table by either using a -1
offset, by loading 'table-1' into an address reg, or by loading the table
address into a reg and then adjusting it. Six of one, 1/24 gross of the
other.
Whenever I am using DBcc in a fixxed count loop, I write the count as
#count-1 for clarity, and to remind myself later that I knew what I was
doing at the time I wrote it.
My pet peeves with the DBcc are twofold. The first is the WORD
limitation, and the second is with the nomenclature that requires me to
have to think in terms of 'Decrement and Branch UNTIL cc'.
Most programmers take a long time to really get the hang of DBcc. Usually
they at first do not realize that the cc is not set as a result of the
count in the loop register going negative, or if they do, they do not
realize the implications of that fact.