Question
This is a NASM assembly question The program checks the number of words on the command line, i.e. argc , and if it is not
This is a NASM assembly question
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 the first command line argument, i.e. argv[1], and if it contains more than one symbol, displays an error message and terminates (e.g. executing proj5 ab 3 will cause this error).
Then it checks that the symbol of the first command line argument is a lower case letter, and if not, displays an error message and terminates (e.g. executing proj5 A 3 will cause this error).
Then it checks the second command line argument, i.e. argv[2], and if it contains more than one symbol, displays an error message and terminates (e.g. executing proj5 a 32 will cause this error).
Then it checks that the symbol of the second command line argument is a digit, and if not, displays an error message and terminates (e.g. executing proj5 a X will cause this error). The digit is converted to a number.
Then the program calls subroutine display_grape passing it the lower case latter and the number it obtained from the command line arguments. After the return from the subroutine, the program terminates.
The subroutine display_grape is mandatory, your program has to have it. It expects two parameters on the stack, the first parameter is the lower case latter (let us call it LETTER to be used, and the second is the size of half-base (let as call it B).
The task of the subroutine display_grape is to display a grape shaped diagram consisting of copies of the letter LETTER with the longest side being 2*B+1 long, e.g. for LETTER being x and B being 3 , it will display:
xxxxxxx xxxxx xxx x
The subroutine display_grape achieves this by a loop that calls a subroutine display_line that displays a single line of the grape shaped diagram. In the above example, display_line would be called 4 times.
The subroutine display_line is mandatory, your program has to have it. It expects three parameters on the stack, the first parameter is a number of spaces it should print, the second parameter is the number of copies of the letter it should print, and the third is the letter to be printed. In the above example, for the top line, display_line would be called with three parameters 0, 7, x, for the next line with 1, 5, x, for the next line wit h 2, 3, x, and and finally for the last line with 3, 1, x.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started