# Assembly Language Question

## Recommended Posts

ashkash    122
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
Sneftel    1788
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
ashkash    122
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
ashkash    122
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.

## Create an account

Register a new account