Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I misled the things needed in the image.. output=6 #include stdafx.h #include #include using namespace std; uint32_t array1ui32[] = { 1, 2, 3, 4, 5,

I misled the things needed in the image..

output=6

#include "stdafx.h"

#include

#include

using namespace std;

uint32_t array1ui32[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

uint32_t array1Elementui32 = sizeof(array1ui32) / sizeof(array1ui32[0]);

uint32_t array2ui32[] = { 111, 222, 333, 444, 555, 666, 777, 888, 999, 1000 };

uint32_t array2Elementui32 = sizeof(array2ui32) / sizeof(array2ui32[0]);

extern "C" { uint32_t AverageFunc(uint32_t, uint32_t[]); }

int _tmain(int argc, _TCHAR* argv[]) {

cout

cout

}

.586 ;Target processor, use Pentium class machines

.MODEL FLAT, C ;Use the flat memory model. Use C calling and return conventions

.STACK ;Define a stack segment of 1KB (Not required for this example)

.DATA ;Create a near data segment. Local variables are declared here (Not required for this example)

.CODE ;Indicates the start of a code segment.

AverageFunc PROC

NoOfElemenstsDW EQU 08

ArrayAddrStartPtr EQU 12

ElementSize EQU Type DWORD

push ebp ;save curent stack frame pointer

mov ebp, esp ;set current stack frame pointer

push esi ;perserve registers for calling program

push ecx

push edx

push ebx

mov ecx, [ebp + NoOfElemenstsDW ] ;get parameters from stack using stack frame into dedicated registers

mov esi, [ebp + ArrayAddrStartPtr ]

;ecx set as NoOfElemenstsDW

;esi set as index pointer

;process the array sum

sub eax,eax ;clear summer

arrayLoop:

; sum into summer

; update index pointer to next element

loop arrayLoop

;take average and calcuate rounding

sub edx, edx

mov ebx, [ebp + NoOfElemenstsDW ]

div ebx

;clear upper dividend

; set divisor from stackset

;edx:eax / ebx

shl edx, 1 ;multiply remainder by 2

cmp edx, ebx ;if 2 x remainder is greater or equal than divisor

jb NoRound

inc eax ; round quotient up to next integer

NoRound: ;endif

pop edx ; restore used registers

pop edx

pop ecx

pop esi ;retore calling bp frame

pop ebp

ret

AverageFunc ENDP

ENDimage text in transcribed

;Target processor, use Pentium class machines Use the flat memory model. Use C calling and return conventions 586 2 MODEL FLAT, C; 4 .STACK 5 DATA 6 7.CODE Define a stack segment of 1KB (Not required for this example) Create a near data segment. Local variables are declared here (Not required for this ex Indicates the start of a code segment 9 AverageFunc PROC NoofElemenstsDW EQU 08 ArrayAddrStartPtr EQU 12 ElementSize push ebp mov ebp, esp 1 EQU Type DWORD ;save curent stack frame pointer ;set current stack frame pointer ;perserve registers for calling program push esi push ecx push ed:x push eb:x 20 21 mov ecx, [ebp + No0fElemenstsDW ] ;get parameters from stack using stack frame into dedicated registers 23 mov esi, [ebp ArrayAddrStartPtr] ;ecx set as No0fElemenstsDW ;esi set as index pointer 25 26 27 28 29 30 31 2 loop arrayLoop process the array sum sub eax, eax arrayLoop: clear summer ; sum into summer ; update index pointer to next element 34 35 ;take average and calcuate rounding sub edx, edx 6 mov ebx, [ebp NoOfElemenstsDW] 37 div ebx 39 10 ;clear upper dividend ; set divisor from stackset ;edx:eax / ebx 12 ;multiply remainder by 2 cmp edx, ebx ;if 2 x remainder is greater or equal than divisor

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro PowerShell For Database Developers

Authors: Bryan P Cafferky

1st Edition

1484205413, 9781484205419

More Books

Students also viewed these Databases questions

Question

Provide examples of Dimensional Tables.

Answered: 1 week ago