Discussion:
SOBGEQ vs SOBGTR
(too old to reply)
Lawrence D'Oliveiro
2024-02-24 03:14:55 UTC
Permalink
... set up loop count in Rn ...
BR 9000$
1000$:
... body of loop ...
9000$: SOBGEQ Rn, 1000$

Why branch and use SOBGEQ instead of SOBGTR? So that, if the loop
count is initially zero, the branch falls right through without
executing the body of the loop.
Arne Vajhøj
2024-02-24 03:29:08 UTC
Permalink
Post by Lawrence D'Oliveiro
... set up loop count in Rn ...
BR 9000$
... body of loop ...
9000$: SOBGEQ Rn, 1000$
Why branch and use SOBGEQ instead of SOBGTR? So that, if the loop
count is initially zero, the branch falls right through without
executing the body of the loop.
With the details provided then it will be pure
speculation.

n = whatever
loop:
if n <= 0 goto endloop
...
n = n - 1
goto loop
endloop:

has more instructions than:

n = whatever
loop:
...
n = n - 1
if n > 0 goto loop

but the second has the problem of not handling the n = 0
case properly.

n = whatever
goto checkfirst
loop:
...
n = n - 1
checkfirst:
if n > 0 goto loop

looks like a hack to fix that problem.

Arne
Arne Vajhøj
2024-02-24 12:58:41 UTC
Permalink
Post by Arne Vajhøj
         ... set up loop count in Rn ...
         BR      9000$
         ... body of loop ...
9000$:  SOBGEQ  Rn, 1000$
Why branch and use SOBGEQ instead of SOBGTR? So that, if the loop
count is initially zero, the branch falls right through without
executing the body of the loop.
With the details provided then it will be pure
speculation.
    n = whatever
    if n <= 0 goto endloop
    ...
    n = n - 1
    goto loop
    n = whatever
    ...
    n = n - 1
    if n > 0 goto loop
but the second has the problem of not handling the n = 0
case properly.
    n = whatever
    goto checkfirst
    ...
    n = n - 1
    if n > 0 goto loop
looks like a hack to fix that problem.
The entire thing reminds me of Fortran 66 vs 77
on DO loops.

Arne

Loading...