tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] short & byte return values


From: Merlin R. Avery Jr.
Subject: [Tinycc-devel] short & byte return values
Date: Fri, 16 Jan 2004 17:22:46 -0600

Earlier I was having trouble with functions that returned shorts or bytes
being switched to their proper type size in eax. I currently fixed it with
the following code.

anyway, at the end of gen_cast it previously had this code:

vtop->type = *type;
}

Now I added this:

    vtop->type = *type;

 // XXXX: Merlin -> Possible fix for short?
 if((sbt & VT_BTYPE) == VT_SHORT
 || (sbt & VT_BTYPE) == VT_BYTE)
  {
  if((sbt & VT_BTYPE) == VT_SHORT)
   {
   if(sbt & VT_UNSIGNED)
    {
    vpushi(state, (1 << 16) - 1);
    gen_op(state, '&');
    }
   else
    {
    vpushi(state, 32 - 16);
    gen_op(state, TOK_SHL);
    vpushi(state, 32 - 16);
    gen_op(state, TOK_SAR);
    }
   }
  else if((sbt & VT_BTYPE) == VT_BYTE)
   {
   if(sbt & VT_UNSIGNED)
    {
    vpushi(state, (1 << 8) - 1);
    gen_op(state, '&');
    }
   else
    {
    vpushi(state, 32 - 8);
    gen_op(state, TOK_SHL);
    vpushi(state, 32 - 8);
    gen_op(state, TOK_SAR);
    }
   }

  }
}

That should make eax contain a proper forumated short / byte.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]