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

ASSEMBLY LANGUAGE (Win32 Console Application solution in the Microsoft Visual St

ID: 3773810 • Letter: A

Question

ASSEMBLY LANGUAGE (Win32 Console Application solution in the Microsoft Visual Studio)

I need to place my two dimensional array process into assembler module (template at the bottom) in the same manner (Count the number of odd values (n mod 2 <> 0) for each row). Important note:Demonstrate assembler module by calling procedures from the C/C++ code.

HERE IS MY TWO DIMENSIONAL PROCESS;

#include "stdafx.h"
#include <cstdio>
#include <cassert>

// Variant implement own function for each grade level , e.g.:
void solution_for_grade_7(const int* arr, size_t arr_rows,                        size_t arr_cols, int* result)
{
int counter = 0;
int modNumb = 2;
__asm
{

  
mov ecx, [arr_rows] // ecx == for(int ROWS = 2;----;----;)
Loop_for_Row:
mov ebx, arr //defining arr here
push ecx //saving row loop counter
xor esi, esi
mov ecx, [arr_cols]
Loop_for_Col :
xor edx, edx
mov eax, dword ptr[ebx + esi] // eax = arr[ROWS][n]
idiv[modNumb] // eax = eax mod 2
cmp edx, 0 // (eax mod 2) == 0 ?
je Skip // jump to Skip, if true
inc [counter]
Skip:
add esi, 4
loop Loop_for_Col // repeat (for COL=N;------;-----) loop
add ebx, esi //next row
pop ecx //restore Loop_for_Row counter i.e. ecx = 2
  
//Store the counted odd values into the result1 array
xor edx, edx
xor eax, eax
mov edx, result
mov eax, [counter]
mov [edx + ecx * 4], eax
mov [counter], 0
loop Loop_for_Row
}
}

const int ROWS = 2;
const int COLS = 3;

int main()
{

// Change the array definitions to be appropriate for your assignments:
int data1[ROWS][COLS] = { { 0, -1, 2 }, { 3, 4, -5 } };
int result1[ROWS] = {}; // Note: for some assignments the result will depend on the COLS!

// Change the parameters according to your assignment function, e.g.:
solution_for_grade_7((const int*)data1, ROWS, COLS, result1);

// Print the result one-dimensional array to the console:
for (size_t i = 0; i < ROWS; i++)
{
printf("%d ", result1[i]);
}
// :::
getchar();
return 0;
}

AND HERE IS TEMPLATE FOR PLACING INTO ASSEMBLER MOBULE;

.586

.model flat, C

.code

SolutionForGrade7 PROC PUBLIC USES ...

[LOCAL ...]

:::

ret

SolutionForGrade7 ENDP

:::

END

Explanation / Answer

// 2D Array of objects Cell[][] grid; // Number of columns and rows in the grid int cols = 10; int rows = 10; void setup() { size(200,200); grid = new Cell[cols][rows]; for (int i = 0; i