Programming Project 3 Solution

$30.00 $24.90

Description

Instructions For this project, you must write three procedures in assembly language. The three procedures will be included in ONE file inside ONE project and called by your main to test them. These procedures should be implemented and tested using the Visual Studio IDE. For all these exercises, you cannot use built-in functions that perform these operations. In case of a doubt, check with your instructor.

For this project, you will build simple strings functions. You will use basic string input/output functions provided by the author of the textbook.

Objectives of this assignment:

  • to improve your programming skills in the assembly language

  • to get familiar with Visual Studio

  • to stress on the fact that the memory (variables) ultimately are 0s and 1s

  • to use some basic string input/output functions

  • to use some basic byte input/output functions

Warning:

The executable you will build may get blocked by an Antivirus scanner on your system. In this case, read this from the Textbook author: “Antivirus scanner software has improved greatly in recent years, and so have the number of viruses (one website reports 50,000 at present). Because of this, your computer’s antivirus scanner may report a false positive when you build your program, and refuse to let you run it. There are a few workarounds: (1) You can add your project’s bin/debug folder into an exclusion list in your antivirus configuration. This is my preferred approach, and it nearly always works. (2) You can suspend your realtime antivirus scanner software, but this will leave you open to malware for a short time. If you choose this option, be sure to temporarily disconnect your computer from the Internet. (3) You can send a copy of your program’s EXE file to the antivirus software vendor, labeling it as a false positive. The virus scanner I use automatically uploads any questionable EXE file to their website and either quarantines or releases the file within about 30 minutes.” I used the first workaround, i.e., I added my project’s /debug folder to the exclusion list in my antivirus configuration.

Input/Output Built-in Functions Allowed:

The textbook author wrote some helpful functions. For this project, you can use these functions:

  1. ReadString: the ReadString procedure reads a string from the keyboard, stopping when the user presses the Enter key. You must pass two parameters before calling this function:

    1. Offset of the buffer where to store the entered string: this offset must be passed in Register EDX

    1. Maximal number of characters: this number is the maximal number of characters a user can enter. This number must be passed in Register ECX.

As a result, ReadString will store in the buffer the string entered by the user and will return in the register EAX the number of characters entered by the user. See excerpt from the textbook:

  1. WriteString: (from the textbook) the WriteString procedure writes a null-terminated string to the console window. You must pass the string’s offset in EDX. Below is a sample call from the textbook:

  1. ReadChar : this function will allow you to read a character from the keyboard and receive its ASCII code in the register AL. This function is described in the textbook Page 165 (beginning/page).

  1. WriteChar : this function will allow you to display on the console window (command window) a character whose ASCII code is stored in the register AL. See in the textbook Page 169 (start/page).

  1. WriteDec : (from the textbook page 169) the procedure WriteDec procedure writes a 32-bit unsigned integer to the console window in decimal format with no leading zeros. You must pass the integer (to display) in the register EAX.

  1. WriteHex : (from the textbook page 169) the procedure WriteHex procedure writes a 32-bit unsigned integer to the console window in hexadecimal format with leading zeros. You must pass the integer (to display) in the register EAX.

====================

Note: the three procedures must be included in ONE project using ONE assembly file. Try to create one procedure for each exercise. Write a main program calling the three procedures. If your exercises are not set as PROCEDURES that can be CALLED from the main or any other procedure, you will loose half of the MAX credit.

Programming Exercise 1 (25 points):

The objective of this exercise is to write a procedure that

  1. Prompts the user with the message: “Please enter a sentence: “

  1. Reads a string S from the keyboard

  1. Displays in decimal the length of the string entered

  1. Displays in hexadecimal the length of the string entered

  1. Displays the string S.

Programming Exercise 2 (30 points):

The objective of this exercise is to write a procedure that

  1. Prompts the user with the message: “Please enter a sentence: “

  1. Reads a string S from the keyboard

  1. Prompts the user with the message: “Please enter a character: “

  1. Reads a character c from the keyboard (use ReadChar)

  1. Computes and displays in decimal the number of occurrences of character c in the string S.

Programming Exercise 3 (45 points):

The objective of this exercise is to write a procedure that

  1. Prompts the user with the message: “Please enter the first sentence: “

  1. Reads the string S1 from the keyboard

  1. Prompts the user with the message: “Please enter the second sentence: “

  1. Reads the string S2 from the keyboard

  1. Concatenates S1 and S2 into a new string S.

  1. Displays S

  1. Displays the length of String S in decimal and hexadecimal format.

What you need to turn in:

  • Post on Canvas the following files:

    1. Electronic copy of your report (standalone)

    1. The source code main.asm (standalone)

    1. Your full project folder that will include your modified main.asm. This project folder must be named first named m6-name where name is your last name. Do not have spaces in the file names. After you correctly name the folder (m6-name), zip it and post it on Canvas.

Your report must:

  • State whether your code works (this should not take more than a sentence). Failing to make this statement can be interpreted that your code does not work correctly and does not meet the requirements

  • Good writing and presentation are expected.

How this assignment will be graded:

  1. The program compiles but does not produce any meaningful result (5%).

  1. The program compiles and executes with major bugs (40% credit).

  1. The program compiles and executes with minor bugs. The code is well designed and commented (90% credit).

  2. The program compiles and executes correctly without any apparent bugs. The code is well designed and commented (100%).

  3. If the instructor needs additional communications/actions to compile and execute your code, then a 30% penalty will be applied.

  4. If the turn-in instructions are not correctly followed, 10 points will be deducted.