• SOBGEQ vs SOBGTR

    From Lawrence D'Oliveiro@21:1/5 to All on Sat Feb 24 03:14:55 2024
    ... 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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Arne_Vajh=C3=B8j?=@21:1/5 to Lawrence D'Oliveiro on Fri Feb 23 22:29:08 2024
    On 2/23/2024 10:14 PM, Lawrence D'Oliveiro wrote:
    ... 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.

    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From =?UTF-8?Q?Arne_Vajh=C3=B8j?=@21:1/5 to All on Sat Feb 24 07:58:41 2024
    On 2/23/2024 10:29 PM, Arne Vajhøj wrote:
    On 2/23/2024 10:14 PM, Lawrence D'Oliveiro wrote:
             ... 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.

    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.

    The entire thing reminds me of Fortran 66 vs 77
    on DO loops.

    Arne

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)