The alternative method to get the prepared files is to enter these commands in the EGTAPI terminal:
mkdir ~/cs255/pj6 For CS255-1 students: cp /home/cs255001/Handouts/pj6/* ~/cs255/pj6 For CS255-2 students: cp /home/cs255002/Handouts/pj6/* ~/cs255/pj6 |
int A, B, GCD; // First, make sure A is largest of the two numbers... if (B > A) { X = A; // Swap A and B A = B; B = X; } while (A != B) { while ( B < A ) { A = A - B; } X = A; // Swap A and B A = B; B = X; } GCD = B;When the algorithm ends, the variable GCD will contain the Greatest Common Divisor of A and B.
Your program can change the values in A and B; I won't check these values when the program ends. I will only check whether GCD variable contains the correct GCD of A and B at the end of execution.
Your assignment is to write the above Euler algorithm in ARM assembler language between the main and Stop labels in pj6.s that will determine the GCD of the integer variables A and B.
The variables A, B, and GCD have already been defined in pj6.s - they are all integer variables.
Also, the variables A and B have been initialized with some value. You need to write the Euler Algorithm beginning at the label main. The GCD computed by the algorithm must be stored in the integer variable GCD.
Note:
|
You may need to add more display variables and/or breakpoints to help you debug the assembler program.
To add a variable:
|
Make sure that:
|
To add a breakpoint (learn more about break points in next section of this handout):
|
You must have defined the label in your program (and compiled it.)
Make sure that:
|
To find bugs in an assembler program, you have to look the the execution of the portion of the program that is in error. First, you have to make the program stop at the place that contains an error - that is done using "break points".
A breakpoint is a location in the program that when the program reaches that location, Egtapi will stop and await your next command. After the program stopped, you can: look at the value of the variables to see if the program has progressed correctly so far.
After examining various things (e.g. variables), you can then choose to continue the execution of the program from the breakpoint with one of these two actions:
When you click on the "Run" button, Egtapi will run the program until it reaches a break point.
When you click on the "Step" button, Egtapi will execute one assembler instruction and stop.
When Egtapi stops, it will show you the current value of all registers and variables that you have requested (in the variable watch window).
The "Step" button is very helpful to find bugs in your program !!
To find bugs in a program, you need to
If the result prodcued by the program differs from what it supposed to do, you found yourself a bug....
Ofcourse, this requires from you that you know what the assembler program is supposed to do. If you don't have a clue about the assembler program is supposed to do, Egtapi will not be much help to you.... - because you do not know what to look for. (Analogy: if you know nothing about radiology, showing you an X-ray picture is useless since you don't know what to look for....)
So to be successful in finding bugs:
Find out what caused the program to stray !
More information on how to find errors in your assembler programs using Egtapi:
|
(In EGTAPI, select: File Browser, Turnin, click on the file you want to turn in (pj6.s), use the turn in code: pj6)
You can also use the turnin command (executed while you're in your cs255 directory)
Open the Terminal in EGTAPI and type in these command:
cd ~/cs255/pj6 /home/cs255001/turnin pj6.s pj6 // If you're in section 1 or /home/cs255002/turnin pj6.s pj6 // If you're in section 2 |
I want the source (so I can read it). DO NOT turn in the executable or the object code !
7. Extension request
However, you need to use pj6 as homework code to make extension for this homework/project.
/home/cs255001/req-ext pj6 // IF you're in section 1 or: /home/cs255002/req-ext pj6 // IF you're in section 2 |
You request will be successful if you have not exceeded the maximum number of "free" (no-questions-asked) requests allowed