Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assembly Language: The first program will involve reading in two numbers from th

ID: 3596907 • Letter: A

Question

Assembly Language: The first program will involve reading in two numbers from the console window, adding them together, and displaying the answer. An example of this contents of the console window is shown below: Enter first number 10 Enter second number 15 The sum is 25 Your console window must look exactly like the above, but, of course, the numbers input can be different. You will create two uninitialized DWORDs called number1 and number2 to contain the unsigned integers input by the user. You will create two strings called prompt1 and prompt2 for the two user prompts shown above. You will create a string called result that will be used to display The sum is. You will create an uninitialized 11 character string called sum to contain the result as a string. The program requires that you use the Irvine library, so you need an INCLUDE Irvine32.inc as the first statement of the program. The standard boiler plate that you normally put at the head of a program is included in Irvine32.inc. You will use 3 procedures from the library: WriteString (writes a string to the console window, where the address of the string is in edx as described below) WriteDec (writes an unsigned decimal to the console window, the decimal must be in eax) ReadInt (reads an unsigned decimal from the console window (after user inputs number and hits enter) and puts it in eax) All of these are used as: call xxxxxx where xxxxxx is the name of the procedure. Before writing a string, you MUST have a statement: mov edx,OFFSET xxxxxx where xxxxxx is the label for the string you want to write.

Explanation / Answer

INCLUDE Irvine32.inc

.data

prompt_1 BYTE "First Number: ", 0

prompt_2 BYTE "Second Number: ", 0

firstNumber DWORD ? ; integer entered by user

secondNumber DWORD ? ; second integer entered by user.

sum DWORD ?

.code

main PROC

top:

mov edx, OFFSET prompt_1

call WriteString

call ReadInt

mov firstNumber, eax

; get secondNumber

mov edx, OFFSET prompt_2

call WriteString

call ReadInt

mov secondNumber, eax

Calculate: ; Calculate Required Values

; sum

mov eax, firstNumber

add eax, secondNumber

mov sum, eax

; Display Results

; sum results

mov eax, firstNumber

call WriteDec

mov edx, OFFSET sumString

call WriteString

mov eax, secondNumber

call WriteDec

mov edx, OFFSET equalsString

call WriteString

mov eax, sum

call WriteDec

call CrLf

exit ; exit to operating system

main ENDP

END main

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote