March 4th, 2012, 09:23 PM
Converting Pseudocode into LC-3 Assembly
In this program I have to bit shifting when multiplying two numbers together. I know the basis of what the program is supposed to have achieve I just don't know the exact way to implement it as my LC-3 skills are lacking a bit.
I need help converting this multiplication algorithm psuedocode
Any help will be much appreciated. Thank you.
March 5th, 2012, 10:57 AM
Re: Converting Pseudocode into LC-3 Assembly
It is better to post code directly into your post, rather than link to an image on another site. So here is the code in that image:
As to your original question, LC-3 doesn't support bit shifting. You will just have to add the number to itself, like in the pseudocode supplied
// Compute product P <— XY
// Y is the multiplicand
// X=x15;x14;x13...x1;x0 is the multiplier
P <— 0 // Initialize product
for i=0 to 14 do // Exclude the sign bit
if X[i] = 1 then
P <— P + Y // Add
Y <— Y + Y // Shift left
Click Here to Expand Forum to Full Width
This is a Codeguru.com survey!