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

Incorrect assembly generated #3

Open
alexfru opened this issue Sep 11, 2021 · 0 comments
Open

Incorrect assembly generated #3

alexfru opened this issue Sep 11, 2021 · 0 comments

Comments

@alexfru
Copy link

alexfru commented Sep 11, 2021

Given this file:

// file: expr_gen.c

int f00(int vr0, int vr1, int vr3, int vr4)
{
  return (vr0 & vr1) ^ (vr3 | vr4);
}

int f01(int vr0, int vr1, int vr3)
{
  return vr3 + vr0 * vr1;
}

int f02(int vr0, int vr1, int vr3, int vr4)
{
  return (vr0 * vr1) + (vr3 * vr4);
}

int f03(int vr0, int vr1, int vr3, int vr4, int vr7, int vr8, int vr10, int vr11,
        int vr15, int vr16, int vr18, int vr19, int vr22, int vr23, int vr25, int vr26)
{
  return (((vr0 + vr1) + (vr3 + vr4)) + ((vr7 + vr8) + (vr10 + vr11))) +
         (((vr15 + vr16) + (vr18 + vr19)) + ((vr22 + vr23) + (vr25 + vr26)));
}

int f04(int vr0, int vr1, int vr3, int vr4, int vr7, int vr8, int vr10, int vr11,
        int vr15, int vr16, int vr18, int vr19, int vr22, int vr23, int vr25, int vr26)
{
  return (((vr0 - vr1) - (vr3 - vr4)) - ((vr7 - vr8) - (vr10 - vr11))) -
         (((vr15 - vr16) - (vr18 - vr19)) - ((vr22 - vr23) - (vr25 - vr26)));
}

int f05(int vr0, int vr1, int vr3, int vr4, int vr7, int vr8, int vr10, int vr11)
{
  return ((vr0 * vr1) + (vr3 * vr4)) * ((vr7 * vr8) + (vr10 * vr11));
}

int f06(int vr0, int vr1, int vr3)
{
  return (vr0 << vr1) << vr3;
}

int f07(int vr0, int vr1, int vr3)
{
  return vr0 << (vr1 << vr3);
}

int f08(int vr0, int vr1, int vr3)
{
  return vr0 << (vr1 * vr3);
}

int f09(int vr0, int vr1, int vr3, int vr4)
{
  return (vr0 * vr1) << (vr3 * vr4);
}

int f10(int vr0, int vr1, int vr3, int vr4)
{
  return (vr0 << vr1) * (vr3 << vr4);
}

int f11(int vr0, int vr1, int vr3, int vr4, int vr7, int vr8, int vr10, int vr11,
        int vr15, int vr16, int vr18, int vr19, int vr22, int vr23, int vr25, int vr26)
{
  return (((vr0 * vr1) + (vr3 * vr4)) * ((vr7 * vr8) + (vr10 * vr11))) *
         (((vr15 * vr16) + (vr18 * vr19)) * ((vr22 * vr23) + (vr25 * vr26)));
}

int f12(int vr0, int vr1, int vr3, int vr4, int vr7, int vr8, int vr10, int vr11,
        int vr15, int vr16, int vr18, int vr19, int vr22, int vr23, int vr25, int vr26)
{
  return (((vr0 * vr1) - (vr3 * vr4)) * ((vr7 * vr8) - (vr10 * vr11))) *
         (((vr15 * vr16) - (vr18 * vr19)) * ((vr22 * vr23) - (vr25 * vr26)));
}

int f13(int vr0, int vr1, int vr3)
{
  return (vr0 / vr1) / vr3;
}

int f14(int vr0, int vr1, int vr3)
{
  return vr0 / (vr1 / vr3);
}

int f15(int vr0, int vr1, int vr3)
{
  return vr0 / (vr1 << vr3);
}

int f16(int vr0, int vr1, int vr3)
{
  return (vr0 / vr1) << vr3;
}

int f17(int vr0, int vr1, int vr3)
{
  return vr0 << (vr1 / vr3);
}

int f18(int vr0, int vr1, int vr3, int vr4)
{
  return (vr0 / vr1) << (vr3 / vr4);
}

int f19(int vr0, int vr1, int vr3, int vr4)
{
  return (vr0 << vr1) / (vr3 << vr4);
}

int f20(int vr0, int vr1, int vr3)
{
  return (vr0 % vr1) % vr3;
}

int f21(int vr0, int vr1, int vr3)
{
  return vr0 % (vr1 % vr3);
}

int f22(int vr0, int vr1, int vr3)
{
  return vr0 % (vr1 << vr3);
}

int f23(int vr0, int vr1, int vr3)
{
  return (vr0 % vr1) << vr3;
}

int f24(int vr0, int vr1, int vr3)
{
  return vr0 << (vr1 % vr3);
}

int f25(int vr0, int vr1, int vr3, int vr4)
{
  return (vr0 % vr1) << (vr3 % vr4);
}

int f26(int vr0, int vr1, int vr3, int vr4)
{
  return (vr0 << vr1) % (vr3 << vr4);
}

int f27(int* vr0)
{
  return 1000 + *vr0;
}

int f28(int** vr0)
{
  return 123 << **vr0;
}

int f29(unsigned char* vr0, signed char* vr1, int* vr2)
{
  return *vr2 = *vr0 + *vr1;
}

int f30(unsigned char* vr0, signed char* vr1, int* vr2)
{
  return *vr2 = *vr1 + *vr0;
}

I do:

c88 expr_gen.c -a
Then
asm88 expr_gen.a

This errors out:

468 ADD AX, BH
error: mismatched types
483 ADD SI, BYTE [DI]
error: mismatched types

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