Answered step by step
Verified Expert Solution
Question
1 Approved Answer
this is Assembly For this assignment, you are going to write your first assembler programs by writing some simple code to use the ADD, MOV,
this is Assembly
For this assignment, you are going to write your first assembler programs by writing some simple code to use the ADD, MOV, SUB, IMUL, and IDIV instructions. Each program below is to be written and tested on the virtual machine given in class and must compile using the nasm assembler and must link using the Id linker. For example, to compile program 1, you will enter the following commands: nasm - g-f elf - F dwarf -o pl.o pl.asm ld pl.o -m elf_i386 -opl Do not use any macros or libraries for this assignment. INrite an assembler language program called pl.asm that prompts the user for two single digit numbers. Once the user has entered the two numbers, the program will add them together, via the add instruction, and print the results. Note that when the numbers are entered, they will be in string form and you will have to convert them into numbers. To convert a single digit number represented as a string into an actual number, you must subtract 48 from it (which is the ASCII code for the character ' 0 '). For example, ' 5 ' ' 0 ' is 5 , and ' 1 ' - ' 0 ' is 1 . You will also need to convert the answer back to a character representation so that it prints correctly. To turn a single digit number into a character representation, add a 48 to it. For example, 5+ ' 0 ' is ' 5 ', and 1+ ' 0 ' is ' 1 '. The algorithm for this first program is below: 1. prompt the user for a single digit number 2. read the number from the keyboard 3. prompt the user for the second single digit number 4. read the second number from the keyboard 5. convert the first number represented as a string to a number by subtracting 48 from it (if the first number is in al, then all you have to do is: sub al, ' 0 ') 6. convert the second number represented as a string to a number by subtracting 48 from t 7. add the first number to the second number and save the answer 8. convert the answer from a number to a string by adding 48 to it 9. print "The answer is: " 10. print the saved answer You can assume the the user will only enter a 1 digit number, so you do not have to do any input checking for this assignment. Also you may assume the the addition of the two numbers will result in a single digit number (of course, this assumption is not valid outside of this assignment, but we have not covered enough to handle this situation, yet). A screenshot for the program is as followsStep 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