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

I have this assembl y code , i need to - Add the necessary I/O needed to read th

ID: 3819317 • Letter: I

Question

I have this assembly code , i need to
- Add the necessary I/O needed to read the data from the user instead of having default digit
- Add the necessary push & pop needed for ( the caller and the callee saves )


TITLE Fill 2D Array ; This program creates and fill 2D array on the stack with a default digit INCLUDE Irvine32.inc .stack 100h .data row = 3 col = 2 arrayA word row dup (col dup (?)) arrayB word row dup (col dup (?)) i word ? j word ? .code main PROC call fill2DA mov eax, 0 call fill2DB mov eax, 0
exit main ENDP fill2DA PROC push ebp mov ebp,esp sub esp,32 mov eax,0 mov i,0 mov j,0 lea esi,[ebp-32] mov ecx, col Loopj: push ecx mov ecx , row
Loopi: mov eax, col ; column size mul i ; row index add ax, j ; column index mov arrayA[eax*2], 5 mov ax, arrayA[eax*2] call WriteDec inc i inc esi loop Loopi call Crlf inc j pop ecx loop loopj add esp,32 pop ebp ret fill2DA ENDP
fill2DB PROC push ebp mov ebp,esp sub esp,32 mov eax,0 mov i,0 mov j,0 lea esi,[ebp-32] mov ecx, col Loopj: push ecx mov ecx , row
Loopi: mov eax, col ; column size mul i ; row index add ax, j ; column index mov arrayB[eax*2], 5 mov ax, arrayB[eax*2] call WriteDec inc i inc esi loop Loopi call Crlf inc j pop ecx loop loopj add esp,32 pop ebp ret fill2DB ENDP END main




I have this assembly code , i need to
- Add the necessary I/O needed to read the data from the user instead of having default digit
- Add the necessary push & pop needed for ( the caller and the callee saves )


TITLE Fill 2D Array ; This program creates and fill 2D array on the stack with a default digit INCLUDE Irvine32.inc .stack 100h .data row = 3 col = 2 arrayA word row dup (col dup (?)) arrayB word row dup (col dup (?)) i word ? j word ? .code main PROC call fill2DA mov eax, 0 call fill2DB mov eax, 0
exit main ENDP fill2DA PROC push ebp mov ebp,esp sub esp,32 mov eax,0 mov i,0 mov j,0 lea esi,[ebp-32] mov ecx, col Loopj: push ecx mov ecx , row
Loopi: mov eax, col ; column size mul i ; row index add ax, j ; column index mov arrayA[eax*2], 5 mov ax, arrayA[eax*2] call WriteDec inc i inc esi loop Loopi call Crlf inc j pop ecx loop loopj add esp,32 pop ebp ret fill2DA ENDP
fill2DB PROC push ebp mov ebp,esp sub esp,32 mov eax,0 mov i,0 mov j,0 lea esi,[ebp-32] mov ecx, col Loopj: push ecx mov ecx , row
Loopi: mov eax, col ; column size mul i ; row index add ax, j ; column index mov arrayB[eax*2], 5 mov ax, arrayB[eax*2] call WriteDec inc i inc esi loop Loopi call Crlf inc j pop ecx loop loopj add esp,32 pop ebp ret fill2DB ENDP END main





- Add the necessary I/O needed to read the data from the user instead of having default digit
- Add the necessary push & pop needed for ( the caller and the callee saves )


TITLE Fill 2D Array ; This program creates and fill 2D array on the stack with a default digit INCLUDE Irvine32.inc .stack 100h .data row = 3 col = 2 arrayA word row dup (col dup (?)) arrayB word row dup (col dup (?)) i word ? j word ? .code main PROC call fill2DA mov eax, 0 call fill2DB mov eax, 0
exit main ENDP fill2DA PROC push ebp mov ebp,esp sub esp,32 mov eax,0 mov i,0 mov j,0 lea esi,[ebp-32] mov ecx, col Loopj: push ecx mov ecx , row
Loopi: mov eax, col ; column size mul i ; row index add ax, j ; column index mov arrayA[eax*2], 5 mov ax, arrayA[eax*2] call WriteDec inc i inc esi loop Loopi call Crlf inc j pop ecx loop loopj add esp,32 pop ebp ret fill2DA ENDP
fill2DB PROC push ebp mov ebp,esp sub esp,32 mov eax,0 mov i,0 mov j,0 lea esi,[ebp-32] mov ecx, col Loopj: push ecx mov ecx , row
Loopi: mov eax, col ; column size mul i ; row index add ax, j ; column index mov arrayB[eax*2], 5 mov ax, arrayB[eax*2] call WriteDec inc i inc esi loop Loopi call Crlf inc j pop ecx loop loopj add esp,32 pop ebp ret fill2DB ENDP END main




- Add the necessary I/O needed to read the data from the user instead of having default digit
- Add the necessary push & pop needed for ( the caller and the callee saves )


TITLE Fill 2D Array ; This program creates and fill 2D array on the stack with a default digit INCLUDE Irvine32.inc .stack 100h .data row = 3 col = 2 arrayA word row dup (col dup (?)) arrayB word row dup (col dup (?)) i word ? j word ? .code main PROC call fill2DA mov eax, 0 call fill2DB mov eax, 0
exit main ENDP fill2DA PROC push ebp mov ebp,esp sub esp,32 mov eax,0 mov i,0 mov j,0 lea esi,[ebp-32] mov ecx, col Loopj: push ecx mov ecx , row
Loopi: mov eax, col ; column size mul i ; row index add ax, j ; column index mov arrayA[eax*2], 5 mov ax, arrayA[eax*2] call WriteDec inc i inc esi loop Loopi call Crlf inc j pop ecx loop loopj add esp,32 pop ebp ret fill2DA ENDP
fill2DB PROC push ebp mov ebp,esp sub esp,32 mov eax,0 mov i,0 mov j,0 lea esi,[ebp-32] mov ecx, col Loopj: push ecx mov ecx , row
Loopi: mov eax, col ; column size mul i ; row index add ax, j ; column index mov arrayB[eax*2], 5 mov ax, arrayB[eax*2] call WriteDec inc i inc esi loop Loopi call Crlf inc j pop ecx loop loopj add esp,32 pop ebp ret fill2DB ENDP END main TITLE Fill 2D Array ; This program creates and fill 2D array on the stack with a default digit INCLUDE Irvine32.inc .stack 100h .data row = 3 col = 2 arrayA word row dup (col dup (?)) arrayB word row dup (col dup (?)) i word ? j word ? .code main PROC call fill2DA mov eax, 0 call fill2DB mov eax, 0
exit main ENDP fill2DA PROC push ebp mov ebp,esp sub esp,32 mov eax,0 mov i,0 mov j,0 lea esi,[ebp-32] mov ecx, col Loopj: push ecx mov ecx , row
Loopi: mov eax, col ; column size mul i ; row index add ax, j ; column index mov arrayA[eax*2], 5 mov ax, arrayA[eax*2] call WriteDec inc i inc esi loop Loopi call Crlf inc j pop ecx loop loopj add esp,32 pop ebp ret fill2DA ENDP
fill2DB PROC push ebp mov ebp,esp sub esp,32 mov eax,0 mov i,0 mov j,0 lea esi,[ebp-32] mov ecx, col Loopj: push ecx mov ecx , row
Loopi: mov eax, col ; column size mul i ; row index add ax, j ; column index mov arrayB[eax*2], 5 mov ax, arrayB[eax*2] call WriteDec inc i inc esi loop Loopi call Crlf inc j pop ecx loop loopj add esp,32 pop ebp ret fill2DB ENDP END main




Explanation / Answer

INCLUDE Irvine32.inc

.stack 100h

.data

prompt db 13, 10, 'rowr:','$'

prompt db 13, 10, 'col:','$'

;Variables

row db ?

col db?

arrayA word row dup (col dup (?))

arrayB word row dup (col dup (?))

i word ?

j word ?

.code

main PROC

call fill2DA

mov eax, 0

call fill2DB

mov eax, 0

exit

main ENDP

fill2DA PROC

push ebp

mov ebp,esp

sub esp,32

mov eax,0

mov i,0

mov j,0

lea esi,[ebp-32]

mov ecx, col

Loopj: push ecx

mov ecx , row

Loopi:

mov eax, col ; column size

mul i ; row index

add ax, j ; column index

mov arrayA[eax*2], 5

mov ax, arrayA[eax*2]

call WriteDec

inc i

inc esi

loop Loopi

call Crlf

inc j

pop ecx

loop loopj

add esp,32

pop ebp

ret

fill2DA ENDP

fill2DB PROC

push ebp

mov ebp,esp

sub esp,32

mov eax,0

mov i,0

mov j,0

lea esi,[ebp-32]

mov ecx, col

Loopj: push ecx

mov ecx , row

Loopi:

mov eax, col ; column size

mul i ; row index

add ax, j ; column index

mov arrayB[eax*2], 5

mov ax, arrayB[eax*2]

call WriteDec

inc i

inc esi

loop Loopi

call Crlf

inc j

pop ecx

loop loopj

add esp,32

pop ebp

ret

fill2DB ENDP

END main