Hey guys,

I have this Java code and I'm trying to convert it to MIPS. I've made an effort and I'm confused to what mistakes I've made.

If anyone knows MIPS, I'd really appreciate some guidance!

When ran in Java, I get these values:
x = 10500531
y = -1374550272
a = 256
b = -1364049997
c = -1364050253

//Bitwise.java

public class BitWise
{
	public static void main( String [] args )
	{
		int x = 0xA039B3FF;
		int y = 0xFFAE1207;
		int a = 0;
		int b = 0;
		int c = 0;
		
		int count = 0;
		
		while( count < 8 )
		{
			x = x >>> 1;
			y = y << 1;
			a = x & y;
			b = x | y;
			c = x ^ y;
			count++;
		}
		System.out.println("X = "+ x);
		System.out.println("y = "+ y);
		System.out.println("a = "+ a);
		System.out.println("b = "+ b);
		System.out.println("c = "+ c);
	}
}
.text
	li $t0, 0		# count = 0
	li $s1, 0xA039B3FF	# x = 0xA039B3FF
	li $s2, 0xFFAE1207	# y = 0xFFAE1207
	li $s3, 0		# a = 0
	li $s4, 0 		# b = 0
	li $s5, 0 		# c = 0
	li $t1, 8		# cutoff value for counting variable
loop:
	addi $t0, $t0, 1	# count++
	xor $s5, $s1, $s2	# x xor y
	or $s4, $s1, $s2	# x or y
	and $s3, $s1, $s2	# x and y
	sll $s2, $s2, 1		# y = y << 1
	srl $s1, $s1, 1		# x = x >>> 1
	blt $t0, $t1, loop	# if counting variable < 8 loop
end:

Cheers,

Wootens

Member Avatar for ztini

Hi, this is a Java forum. Please repost your question to the Legacy forum.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.