Discussion:
Homework #5, Question #2
(too old to reply)
William R. Lorenz
2005-11-12 23:39:48 UTC
Permalink
Homework #5 question #2 asks us to write assembly code that will "set
bits m:n in %r9 to 1." I did this in about 30 lines of code, but I have
to wonder if there's a more efficient way to do this? Has anyone done
this in just a few lines of code? Am I missing something obvious? :)
B A Bair
2005-11-13 14:19:57 UTC
Permalink
There are about three different solutions, none of which take more than
eight lines of SPARC code.

You might find it helpful to review the slides about bit manipulation.

;-)
Homework #5 question #2 asks us to write assembly code that will "set bits
m:n in %r9 to 1." I did this in about 30 lines of code, but I have to
wonder if there's a more efficient way to do this? Has anyone done this
in just a few lines of code? Am I missing something obvious? :)
Grant
2005-11-16 00:59:21 UTC
Permalink
I tried to to it using loops, and breached the "8-line limit."
So, I don't think we're supposed to use loops to do this.

Grant
Post by B A Bair
There are about three different solutions, none of which take more than
eight lines of SPARC code.
You might find it helpful to review the slides about bit manipulation.
IV
2005-11-17 17:30:04 UTC
Permalink
Post by Grant
I tried to to it using loops, and breached the "8-line limit."
So, I don't think we're supposed to use loops to do this.
If you don't put labels on their own lines, you can do it in seven
with a single loop.

Loading...