| Date Assigned: | Fri Sep-29 |
| Date Due: | Tue Oct-3 by start of class (earlier submissions preferred, however) |
This is an entirely Extra Credit assignment (for those students interested in independent study in this course: this is an excellent opportunity to demonstrate that you should be given such an opportunity... hint, hint...). Anyhow, hopefully, some of you will be inspired to work on it! In any case, have a most merry weekend. By the way, we are 1/8th of the way through the school year. So far, so good!
This assignment involves the use of subroutines (though you can get some extra credit without knowing subroutines). These were described in class yesterday for those students who finished their assignments ahead of class. If you are unsure of what a subroutine is or how to create one, please ask me or your classmates for help. You may also consult the demonstrational file subroutineDemo.asm.
Here are some questions for our "Assembly Language Programmers' FAQ". Your task here, if you are so inclined, is to create a little web page with clear, concise answers to these questions. Please also add more interesting questions which would help others who use the SimpSim assembly language development environment.
Here, you must have decent formatting -- the goal is to create a web page which is really usable by real people (students like yourselves in classes like this one).
Again, these are just some questions you may answer:
The goal here is to help round out the subroutine library we are developing. Write subroutines which do interesting things (how about that for specificity?). Document your subroutines well, so it is very clear:
Also, provide some simple test code to verify that your subroutine works properly.
- what the subroutine does
- what registers it uses for inputs (generally use R5-R9, if possible)
- what registers it sets for outputs (if possible, reuse input registers as output registers)
- what registers it mangles for temporaries (try to minimize this, and try to generally use RA-RE for this)
Here are the kinds of subroutines which you might want to write (and, yes, you may write these, though these will hopefully inspire you to think of other, even more interesting ones to write):
- Multiply R5,R6,R7
This sets R5 to the result of multiplying R6 by R7. Because there is no multiply command, you will have to do this as a series of additions (well, there is a faster way, but you do not have to come up with it). Just keep a counter, say RA, which counts from 0 to R7, and with each count just increase R5 by the value in R6. Be sure to first set R5 to zero, and also to verify that R7 is not negative (it is ok to work only over positive numbers, if you say so in your comments, but more extra credit goes to those who work over negatives, too).- Divide R5,R6,R7
This sets R5 to the result of dividing R6 by R7. Here, I mean integer division with no remainder, so 19/5 equals 3 and 26/4 equals 6. How to do this? First, same deal regarding positives and negatives as with multiply (so it's ok to assume positives, but better to work for all numbers). Now, set R5 to zero, and set a summator, say RA, to 0. Keep adding one to R5 and adding R7 to RA until RA is greater than R6 (be sure not to add one to R5 that last time!). Simple.- Square R5
This sets R5 equal to the square of the number in R5. You will likely want to use Multiply, defined above, for this one.- ToUpperCase R5
This converts all the lowercase text that R5 points to to uppercase, while ignoring the rest of the text. So, if R5 points to the text "This is a test!!!", with a 0 terminator, then after this call R5 would point to "THIS IS A TEST!!!"- ToLowerCase R5
The sibling of ToUpperCase.- EliminateExtraSpaces R5
This one eliminates the extra spaces in the text R5 points to. So if R5 points to "This is a test with extra spaces", then after this call R5 would point to "This is a test with extra spaces".- PalindromeTest R5,R6
This is a harder one. It loads R6 with 0x01 if the text R5 points to is a palindrome, and 0x00 otherwise. What is a palindrome? It is text which is the same backwards as forwards. So if R5 points to "madam" or "abcdcba", then this would load R6 with 0x01, but if R5 points to "tada" or "abcdcab", then this would load R6 with 0x00.- Et cetera, et cetera, et cetera
There are plainly an infinite number of these kinds of interesting functions. The more you write, the better your grade. And it's fun, too! :-)