Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NASM assembly program: The program checks the number of words on the command line, i.e. argc , and if it is not equal to 3,

NASM assembly program:

The program checks the number of words on the command line, i.e. argc , and if it is not equal to 3, displays an error message and terminates (e.g. executing proj5 will cause this error).

Then it checks whether the first command line argument is a string of length 1 or 2, i.e. whether argv[1]contains less than one or more than two symbols. If so, it displays an error message and terminates (e.g. executing proj5 100 M will cause this error).

Then it checks that the symbol or symbols of the first command line argument are digits, and if not, displays an error message and terminates (e.g. executing proj5 A M will cause this error).

Then it converts the one or two symbols of argv[1]into a corresponding number and stores the number in memory.

Then it checks whether the second command line argument is a string of length 1, and if not, displays an error message and terminates (e.g. executing proj5 23 bb will cause this error).

Then it checks whether the single symbol of argv[2] is an upper case letter, and if not, it displays an error message and terminates (e.g. executing proj5 23 a will cause this error).

Then it converts the single symbol of argv[2] into corresponding lower case and stores it in memory.

Then the program calls subroutine display_triangle passing it the number as the first argument and the lower case latter as the second argument. After the return from the subroutine, the stack is properly cleaned and the program terminates.

The subroutine display_triangle is mandatory, your program has to have it. It expects two arguments on the stack, the first argument is a number and the second argument is a dword whose lowest byte contains the lower case letter.

The task of the subroutine display_triangle is to display a triangle shaped diagram consisting of copies of the lower case letter with the length of the bottom side being the number it received. For instance, if the number is 4 and the lower letter is m, it will display:

 m mm mmm mmmm 

The subroutine display_triangle achieves this by a loop that calls a subroutine display_line that displays a single line of the triangle shaped diagram. In the above example, display_line would be called 4 times. After the call, the stack is properly cleaned.

The subroutine display_line is mandatory, your program has to have it. It expects three parameters on the stack, the first parameter is the number of spaces it has to print, the second is the number of copies of the lower case letter it must print, and the third is a dword that contains in its lowest byte the lower case letter to be used. In the above example, for the top line, display_line would be called with three parameters 3, 1, m, for the next line with 2, 2, m, for the next line with 1, 2, a and finally for the last line with 0, 4, a.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions

Question

What is an ANOVA table?

Answered: 1 week ago

Question

3. Review the evidence. Do you believe the testimony presented?

Answered: 1 week ago

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago