Difference between revisions of "CSC231 Homework 5 2017"

From dftwiki3
Jump to: navigation, search
(Solution Executable)
(Solution Executable)
Line 23: Line 23:
 
<br />
 
<br />
  
 +
<br />
 +
<br />
 
==Solution Executable==
 
==Solution Executable==
 
<br />
 
<br />
Line 84: Line 86:
 
  **&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**
 
  **&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;**
 
  *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*
 
  *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*
 +
 +
In this case the solution output in on the right, and the blank line in your output indicates that your output is missing a line that is found in the solution output.  You can then modify your program to make it work perfectly well.
 +
 +
Note that it is normal for the 6 that the user entered not to be found in the output.  That's a side effect of redirecting the output of programs to files: the keyboard input is not captured.
 +
<br />
 +
==Submission==
 +
<br />
 +
Submit your asm file (not the executable) to Moodle.  You won't be able to run or evaluate it, so make sure your program works exactly as the solution program!!!
 +
<br />

Revision as of 07:35, 25 March 2017

--D. Thiebaut (talk) 08:12, 25 March 2017 (EDT)



This homework is due on 4/3/17, at 11:55 p.m.


Problem #1


Write an assembly language program called hw5_1.asm that prompts the user for an integer, and prints out a pattern of stars representing a triangle, a square, and another triangle.
Here is an example where the user enters 5 when prompted by the program:

Hw5 1.png


Note that the output corresponds to 3 geometric patterns: a triangle of 5 lines, a square of 5 lines, and another triangle of 5 lines. The width of the square and triangles is 5 star (max length of a line).


Hw5 1top.png Hw5 1middle.png Hw5 1bot.png



Solution Executable


The executable version of the solution program is available for you to play with. Get a copy of it as follows:

getcopy hw5_1sol


and run it a few times to see how it works:

./hw5_1sol

You can compare the output of your program to the solution program by running these linux commands (we assume that we want to test the two programs with an input of 6):


231b@aurora hw5 $ cat > input.txt
6
^D          (type Control-D then ENTER to indicate end of input)
231b@aurora hw5 $ ./hw5_1 < input.txt > output.txt
231b@aurora hw5 $ ./hw5_1sol < input.txt > outputsol.txt
231b@aurora hw5 $ diff -y output.txt outputsol.txt  
> *                                                                > *
**                                                                 **
***                                                                ***
****                                                               ****
*****                                                              *****
******                                                             ******
******                                                             ******
******                                                             ******
******                                                             ******
******                                                             ******
******                                                             ******
******                                                             ******
******                                                             ******
*****                                                              *****
****                                                               ****
***                                                                ***
**                                                                 **
*                                                                  *

If your output does not match the solution output, you will see a special character

> *                                                                > *
**                                                                 **
***                                                                ***
****                                                               ****
*****                                                              *****
******                                                             ******
******                                                             ******
******                                                             ******
******                                                             ******
******                                                             ******
******                                                             ******
******                                                             ******
                                                                >  ******
*****                                                              *****
****                                                               ****
***                                                                ***
**                                                                 **
*                                                                  *

In this case the solution output in on the right, and the blank line in your output indicates that your output is missing a line that is found in the solution output. You can then modify your program to make it work perfectly well.

Note that it is normal for the 6 that the user entered not to be found in the output. That's a side effect of redirecting the output of programs to files: the keyboard input is not captured.

Submission


Submit your asm file (not the executable) to Moodle. You won't be able to run or evaluate it, so make sure your program works exactly as the solution program!!!