Difference between revisions of "CSC231 Homework 4 2014"

From dftwiki3
Jump to: navigation, search
(Problem #2: Documentation and Style)
Line 77: Line 77:
 
Submit your program to the '''Homework 4 Problem 3''' section in Moodle.
 
Submit your program to the '''Homework 4 Problem 3''' section in Moodle.
 
<br />
 
<br />
 +
=Problem #4=
 
<br />
 
<br />
 +
Will be provided later on 10/21/14...
 
<br />
 
<br />
 
<br />
 
<br />

Revision as of 07:42, 21 October 2014

--D. Thiebaut (talk) 07:11, 21 October 2014 (EDT)


The assignment is due on 10/28/10 at 11:55 p.m.





Problem #1: Addressing modes and one-dimensional arrays


Assume that your data section is initialized with the following variables:

      msg     db    3,"ALL",11,"PROGRAMMERS",3,"ARE",11,"PLAYWRIGHTS"
              db    3,"AND",3,"ALL",9,"COMPUTERS",3,"ARE",5,"LOUSY"
              db    6,"ACTORS"
      N       equ   10


Note that the msg contains byte numbers followed by words. The byte number preceeding a word corresponds to the number of letters in the word. So '3,"ALL"' for example means that the word that follows 3 is a 3-character word. '11,"PROGRAMMERS"' means that the string following the byte that contains 11 is an 11-character word.

N represents the total number of words in the string msg.

Your assignment is to write a program that uses one or several loops that go N times and that print all the words on separate lines, one after the other, such that each word is capitalized, i.e. its first letter is uppercase, and the others are lowercase.


Submission


Submit your program in Moodle's Homework 4, Problem 1 section.

Problem #2: Documentation and Style


Take your solution program for Problem 1, above, and document it fully. Use past solution programs as examples. Your program should have:

  • A header, containing the name of the program (its file name), the name of the author, a description of what it does (and possible bugs you may know it to contain, and how one should assemble, link, and run it
  • Markers highlighting where the data section and code section are located
  • Comments throughout the code indicating what the various blocks of instructions do. Do not hesitate to add blank lines in your code to separate logical blocks. Make sure your comments help understand how the computation progresses, rather than what the instruction is doing.


For example, here is a bad way of documenting an instruction:


             inc        ebx              ; increment ebx


This is not very helpful because we are not learning anything more about what the code is doing. Instead, if eax is a pointer to a list of characters, a more useful comment would have been:


             inc        ebx              ; move ebx to the next character in string


  • You do not have to document each instruction. Only those that are important, or where having some additional details would help.
  • Make sure you use variables that have self-documenting names. x, a, for example, do not carry much information. But message, char, or index are much better.


Submission


You need to submit your fully documented program to a different section of Moodle. Your program will not be run or evaluated automatically. Instead I will download it from Moodle later, so that I can read it, annotate it, and comment on your programming style. You won't be able to run or evaluate this problem with Moodle.

Problem #3


Take your solution program (or my solution program) for Homework 3, Problem 5, and rewrite it so that it uses functions.
Your solution program should have several functions:

  • One function called printLn that prints a new-line character (0x0a). It will replace our _println function. Your function must use int 0x80 to print the 0x0a char. Your function should not call _println! printLn does not receive any parameter through registers, and must save all the registers it uses. In other words, when we return from printLn, all the registers will contain the same values they had before we called the function.
  • One function called printMsg that prints a string on the screen. printMsg will replace our _printString function. Your function must use int 0x80 to print the string. It will get the address of the string to print in ecx and the number of characters in the string in edx. This function should not call _printString. It must use the int 0x80 instruction.
  • One function called printFibMsg that gets a number in eax and prints the string Fibonacci(###) where ### is the decimal value of the number in eax. You should call _printDec inside printFibMsg to print the number passed in eax.

Your printFibMsg function should save all the registers it modifies and should return them to their original values.

Submission


Submit your program to the Homework 4 Problem 3 section in Moodle.

Problem #4


Will be provided later on 10/21/14...