Name _________________________
Machine and Assembly Language Worksheet
Given an instruction or instruction sequence which accomplish the following objectives in ISCAL.
static int gcd(int x, int y)
{
int temp;
if( x < 0 ) x = -x;
if( y < 0 ) y = -y;
/* assert x >= 0 && y >= 0 */
while( true )
{
if( x > y )
{
temp = x;
x = y;
y = temp;
}
/* assert x <= y */
if( x == 0 )
break;
y = y - x;
}
return y;
}