Tri H.

asked • 12/11/20

Getting frustrated for the programming question below. Please give me a hand for some help.

Utilizing the same windows32 framework below, implement a program that will use a dialog box to prompt for an integer n, compute the sum 12 + 22 + . . . + n2 , and use a message box to display the sum. Use a loop in the implementation.

.586

.MODEL FLAT


INCLUDE io.h           ; header file for input/output


.STACK 4096


.DATA

number1 DWORD  ?

number2 DWORD  ?

prompt1 BYTE   "Enter first number", 0

prompt2 BYTE   "Enter second number", 0

string BYTE   40 DUP (?)

resultLbl BYTE "The sum is", 0

sum    BYTE   11 DUP (?), 0


.CODE

_MainProc PROC

       input  prompt1, string, 40     ; read ASCII characters

       atod   string         ; convert to integer

       mov    number1, eax   ; store in memory


       input  prompt2, string, 40     ; repeat for second number

       atod   string

       mov    number2, eax

       

       mov    eax, number1   ; first number to EAX

       add    eax, number2   ; add second number

       dtoa   sum, eax       ; convert to ASCII characters

       output resultLbl, sum         ; output label and sum


       mov    eax, 0 ; exit with return code 0

       ret

_MainProc ENDP

END                            ; end of source code

1 Expert Answer

By:

Siddharth S. answered • 12/24/20

Tutor
New to Wyzant

Here to help you!!

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.