-
March 4th, 2012, 10:23 PM
#1
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
http://imageshack.us/photo/my-images/43/capturelo.jpg/
Any help will be much appreciated. Thank you.
-
March 5th, 2012, 11:57 AM
#2
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:
Code:
// 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
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|