Sign in to follow this  

Assembly Language Question

This topic is 4032 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I need to write an assembly program to plot a line. There is one contraint that I need to follow and this is what it is: The X and Y coordinates should be packed in $5 as two six bit, signed two’s complement values. X is passed in bits 11-6; Y is passed in bits 5-0. All other bits should be zero. I am having trouble doing this. Basically I have been given an instruction that will plot a point but the coordinates of the point must be in $5 as described above and I do not know how to go about doing this. I am using MIPS assembly language. Any help would be appreciated. thanks.

Share this post


Link to post
Share on other sites
Assuming you have X and Y in registers and that each one is in the apporpriate range, first you cut X and Y down to size. To do that, you can just AND each one with 63 to zero out everything above the sixth bit. Once you've done that, just shift the X value left by 6 bits, and OR it with the Y for the final result.

Share this post


Link to post
Share on other sites
I tried what you wrote but am still not getting it. Here is what I am doing.
X is in $12 and Y is in $11.

andi $12, $12, 63
andi $11, $11, 63
sll $10, $12, 6
or $5, $10, $11


sll is shift left logical. $10 = $12 << 6

Any help would be appreciated. thanks.

Share this post


Link to post
Share on other sites

This topic is 4032 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this