[Coco] CC issue
Walter Zambotti
zambotti at iinet.net.au
Tue Nov 12 21:37:54 EST 2019
Robert
Tried all three of those examples and they all exhibit the same issue.
The asm code is added inside the loop!
As I mentioned before each of those can be fixed by adding a ';' before the #asm or after the loop.
Walter
-----Original Message-----
From: Coco [mailto:coco-bounces at maltedmedia.com] On Behalf Of Robert Gault
Sent: Monday, 11 November 2019 9:00 PM
To: CoCoList for Color Computer Enthusiasts <coco at maltedmedia.com>
Subject: Re: [Coco] CC issue
Walter,
I've been trying to make sense of your problem even thought it "is not meant to be logical". :) Seems to me that your problem is not an issue with the C command modules but your syntax.
Try the following variations on what you posted.
main()
{
int I;
while(i++)
i--;
#asm
clra
clrb
#endasm
i=i + 1;
}
main()
{
int I;
while(i++)
{i--;}
#asm
clra
clrb
#endasm
i=i + 1;
}
main()
{
int I;
while(i++)
{
i--;
}
#asm
clra
clrb
#endasm
i=i + 1;
}
Do any of the above fail by including the #asm within the while loop?
Robert
Walter Zambotti wrote:
> I found a small issue in both c.pass1/2 and o c_comp.
>
>
>
> In the following demonstrative code (which is not meant to be logical):
>
>
>
> main()
>
> {
>
> int I;
>
> while(i++) { i--;}
>
> #asm
>
> clra
>
> clrb
>
> #endasm
>
> i = i + 1;
>
> }
>
>
>
> The asm code is incorrectly placed inside the while loop.
>
>
>
> This occurs because the compiler is looking for a semicolon after the
> loop block. Which of course is not required and is tolerated.
>
> However while it is looking for the semicolon if it comes across any
> comments it outputs them immediately doing so before it has finalised
> the output for the loop.
>
>
>
> This issue does effect program execution.
>
>
>
> The easy work around is to place an extraneous semicolon after the
> loop block like so:
>
>
>
> while(i++) { i--;};
>
> or
>
> while(i++) i++;;
>
>
>
> This forces the compiler to place the asm code after the loop as expected.
>
>
>
> This occurs for any statement block that contains exit logic such as:
>
>
>
> While, for, switch
>
>
>
> This also affects C lines added as comments to the assembly. The C
> comment lines appear out of context to their respective asm.
>
>
>
> This last issue does not effect program execution but makes it
> difficult to use the assembly listing to debug your code.
>
>
>
> I have traced through c.comp extensively and the fix would not be easy.
>
>
>
> I did however manage to add a fix to c.prep so that it outputs a
> semicolon before any asm code. This seems to fix the issue but would
> need extensive testing.
>
>
>
> Walter
>
>
--
Coco mailing list
Coco at maltedmedia.com
https://pairlist5.pair.net/mailman/listinfo/coco
More information about the Coco
mailing list