[Coco] C Coding question
Jeff Teunissen
deek at d2dc.net
Mon Dec 30 13:05:51 EST 2024
On Wed, Dec 25, 2024, 23:13 dlb via Coco <coco at maltedmedia.com> wrote:
> I'm disassembling a program and came across something that was
> interesting, to say the least. Here's what I have:
>
[snip]
L0762()
{
> /* Why did they do this ?? Wouldn't (D0035 < D0037 work? */
> while ((D0035 >= D0037) == 0)
> {
> if ((L1fca() != 0) || (L2474(1) == -1))
> {
> break;
> }
> }
> }
>
> The comment in the code above states my question. Wouldn't what my
> suggestion do the same? I cannot understand why anyone would write
> code like that unless there's something I am missing.
>
Looks like the L2474() function is, or calls, a system call (which return
-1 for any error), and calls it with the path number 1 (the standard output
path)? Anytime I see a "cmpd #-1" in C code I start thinking system call.
As for the test, I can't think of any obvious reasons someone would write
"while (!(var1 >= var2))" rather than "while (var2 < var1)" except for
inverting the meaning of code emitted by a macro. So I would think there
was likely a macro like
#define STATE (var1 >= var2)
such that code like
while (!STATE) {
...
}
might make sense.
Looks like the function might be writing chunks of text somewhere, and 0x35
and 0x37 are pointers?
More information about the Coco
mailing list