CmpSci 201 Project 1 Description ------------------------ In this project you will familiarize yourself with the rolecks/swatch system and implementing a simple looping function. Getting rolecks --------------- Rolecks is available off of the course website (www.cs.umass.edu/~trekp/cs201). It is an executable Jar file, so any system running a reasonably recent version of Java should be able to run it. Make sure you get the latest version! Rolecks is regularly being extended and improved (read: bug fixes). Make sure you grab a recent copy before starting. Loading and running your code ----------------------------- You can write your code in your text editor of choice. To assemble it, click on the 'assemble file' button in rolecks. This will generate a simple binary version of the file (if the file was named foo.s the binary form will be named foo.bin). To load up the binary, click on the 'Open Executable' button in rolecks. The problem ----------- The problem is to determine whether or not the value in R1 is a perfect square, and if so, of which number it is a square. When your program begins, there will be a value in R1. Your code must examine this value (somehow) and decide whether or not it is a perfect square. If it is, your program should write the square root of R1 into R2. If the value in R1 is not a perfect square, your program should write the value -1 into R2. Ex. R1 = 25 R1 = 20 R1 = 25 R1 = 20 R2 = 5 R2 = -1 Bear in mind that the simulator will display these values in hexadecimal 2's complement form, so -1 will show up as 0xffffffff. Also, to indicate that your program has finished, you'll need to use the special SWI instruction. So, at the end of your program you should have a line that looks like this: SWI #h00900001 At the moment, this may seem mysterious, but all will become clear later. Hint: You will almost certainly have to loop in order to check the value in R1. Try writing out the code in Java-ish pseudo code first to make sure you're checking the right things. Then, translate into ARM. When you become more comfortable with condition codes and predication you should be able to write out this stuff directly. For now, though, save yourself some pain and start with a language you know. Testing your code ----------------- To test your code you'll need to put test values in R1. There are two ways of doing this. First, you can just write code that loads an immediate value into R1 before entering the "real" code (using MOV, perhaps). If you do this, remember to remove this test code before submitting! The second option is to set the value of the registers before you begin, set R1 by clicking on the button, type in the value (in hex), and then continue execution. At first, this may seem more daunting, but it will get you used to debugging and so will be beneficial in the long run. Submitting your code -------------------- Submit your code by e-mailing to trekp@cs.umass.edu a message with: "CS201 Project 1 Submission, " in the subject line, where "" is replaced with your actual name. Attach the source code, which should be in a file named "proj1.s" to the message.