# Assembly Language Question

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

## 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 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 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 on other sites
it is working now. sorry about that, your algorithm was correct and there was something else in my code that was giving me the error. thanks for your help.

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631428
• Total Posts
3000027
×