Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Declaring an array in the project create worse output #885

Open
blindmatrix opened this issue Jun 24, 2020 · 0 comments
Open

Declaring an array in the project create worse output #885

blindmatrix opened this issue Jun 24, 2020 · 0 comments

Comments

@blindmatrix
Copy link
Contributor

(same sample program as the two previous issues):
RekoIssueArrayIndex-arraystruct.zip

The included .dcproject file contain an entry for a global array. Removing it give this output:

typedef struct Eq_25 {	// size: 1 1
	word16 w0000;	// 0
} Eq_25;

Eq_25 g_a403000[] = 
	{
	};

Eq_2 Win32CrtStartup()
{
	word16 wLoc08_35 = 0x00;
	if (true)
	{
		do
		{
			g_a403000[(word32) wLoc08_35 * 2] = (struct Eq_25) (word16) ((word32) wLoc08_35 * 0x02);
			cup16 ax_24 = (word16) (word32) wLoc08_35;
			wLoc08_35 = ax_24 + 0x01;
		} while (ax_24 < 65505);
	}
	ExitProcess(0x00);
}

where the array is identified as a structure with a single field. If I instead enable the global, the generated output explodes into

struct <anonymous> theArray[32] = ....;

Eq_2 Win32CrtStartup()
{
    word16 wLoc08_35 = 0x00;
    if (true)
    {
        do
        {
            *((char *) globals->theArray + (word32) wLoc08_35 * 0x02) = (union Eq_28 *) (word16) ((word32) wLoc08_35 * 0x02);
            cup16 ax_24 = (word16) (word32) wLoc08_35;
            wLoc08_35 = ax_24 + 0x01;
        } while (ax_24 < 65505);
    }
    ExitProcess(0x00);
}

The array (theArray) is declared as uint16 theArray[32] = ... after scanning and "analyze dataflow", but break during "reconstruct data types" when it instead is treated as a struct containing a single word16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant