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

***** Assembly Language 80X86 **** The following design will input numbers into

ID: 3827671 • Letter: #

Question

***** Assembly Language 80X86 ****

The following design will input numbers into an array of doublewords, using the sentinel value -9999 to terminate input. nbrElts := 0 get address of array prompt for and input number while number != -9999 loop add 1 to nbrElts store number at address add 4 to address prompt for and input number end while Implement this design in a windows32 program that uses a dialog box to prompt for and input each number. Assume that no more than 100 numbers will be entered. Use a single message box to report the sum of the numbers and how many numbers were entered (not counting the sentinel value).

Explanation / Answer

code:

.MODEl FLAT

INCLUDE io.h

;exit process declaration

ExitProcess PROTO NEAR32 stdcall, dwExitCode:DWORD

;declaring constants

car           EQU 0dh

lineFedd EQU 0ah

AllowedCnt    EQU 100

.STACK 4096

;data section

.DATA

info      BYTE 'Enter up to 100 numbers'

getInput BYTE 'Enter value?',0

enterVal BYTE 20 DUP (?)

nbrElts       DWORD ?

myAry         DWORD AllowedCnt DUP(?)

mySum         BYTE 10 DUP (?),car,lineFedd,0

sumStr        BYTE car,lineFedd,lineFedd,'The sum is'

cntStr BYTE car,lineFedd,lineFedd,'The number of elements is'

;code section

.CODE

_start:

     output info

     mov nbrElts,0

     lea ebx,myAry

     output getInput

     input enterVal,20

     atod enterVal

while: cmp enterVal,-9999

     je whileEnd

     inc nbrElts

     mov [ebx],eax

     add ebx,4

     output getInput

     input enterVal,20

     atod enterVal

     jmp while

    

whileEnd:

     mov eax,0

     lea ebx,myAry

     mov ecx, nbrElts

     jecxz endExec

forLoop: add eax,[ebx]

     add ebx,4

     loop forLoop

     dtoa mySum,nbrElts

     output cntStr

     output mySum

     dtoa mySum,eax

     output sumStr

     output mySum

    

endExec: INVOKE ExitProcess,0

PUBLIC _start

     END