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

Create an masm assembly program and assign the values of variables that are decl

ID: 3583390 • Letter: C

Question

Create an masm assembly program and assign the values of variables that are declared BEFORE the array to an array that appears below it. There should be a “flexible” amount of variables(Do not hardcode the number of variables) To accomplish this you will have to create an array that will be larger than the most variables that you will ever place in the array. Please use the followinf template:

; Program template

.386
.model flat,stdcall
.stack 4096
ExitProcess proto,dwExitCode:dword

.data
   ; declare variables here
.code
main proc
   ; write your code here

   invoke ExitProcess,0
main endp
end main

Explanation / Answer

; Program template

.386
.model flat,stdcall
.stack 4096
ExitProcess proto,dwExitCode:dword

.data

; declaring variables

NVAR DB ?

dwArray1 dword NVAR dup (?)

dwArray2 dword NVAR dup (?)

MSG1 DB 10,13,"Enter the numer of variables: $"

MSG2 DB 10,13, "Enter the variables: $"

MSG3 DB 10,13, "Original Array is: $"

MSG4 DB 10,13, "Final Array is: $"

.code
main proc

call clrscr

call crlf

mov edx, offset MSG1 ; Read number of variables

call writestring

call readint

mov edx, offset MSG2 ; Read the variables

call writestring

call readint

call clrscr

call crlf

mov edx,offset MSG3 ; Copy the variables into first array

call writestring

call crlf

mov edx,offset dwArray1

call writestring

call crlf

call crlf

mov ecx,NVAR

L1:

mov esi,0

mov al,dwArray1[esi] ; Copy the contents of array1 to array2

mov target[esi],al

inc esi

loop L1

mov edx,offset MSG4

call writestring

call crlf

mov edx,offset dwArray2 ; display the contents of array2

call writestring

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