Question: NASM Program with Subroutines In this assignment, you are going to first implement the code to perform character to integer and integer to character conversion

NASM Program with Subroutines In this assignment, you are going to first implement the code to perform character to integer and integer to character conversion from Assignment 2 as subroutines callable from an assembly language main program. Then you are going to modify the main program to call these subroutines from different places. First, implement the following NASM subroutines by extracting the necessary code from your Assignment 2 program. print(str, len): prints the character string of length len stored at address str on the standard output device (screen). iprint (int): prints the specified signed integer int on the standard output device (screen) after converting it into the appropriate character string. prln: prints the linefeed character at the end of the current output line so that the next output will go to a new line. iread(int): reads a signed integer from the standard input device (keyboard) and returns the binary integer in int. Then add a while loop to your NASM main program so that the main program reads a signed integer from the keyboard, performs the calculations on the input integer and prints the results with appropriate annotations until the user enters an empty line. Specifically, your NASM assembly language main program should do the following within the while loop. Read a signed integer number (up to 4 digits) from the standard input device (keyboard) by calling the iread function. Exit the loop iff the user does not enter any number (that is, enters an empty line). Otherwise, keep the binary integer read in both the eax and ebx registers. Print the input data in a line on the standard output device (screen) by calling the prln function with a description like (if the input number is 1234): The entered number is 1234 This can be done by first printing the annotation (The entered number is) using the print function, then printing the number using the iprint function followed by the prntln function to print the next output on a new line. Divide the input data by two by shifting the contents of the eax register to the right by one bit. Print the resultant data correctly in a line with a description like Half of the entered number is 617 Multiply the input data by two by shifting the contents of the ebx register to the left by one bit and print the resultant data correctly in a line with a description like Double of the entered number is 2468 Print two empty lines to signify the end of this iteration and then go the next iteration of the loop.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!