this is assembly language for x-86 processors using microsoft visual studio
Create a procedure named FindThrees that returns 1 if an array has three consecutive values of 3 somewhere in the array. Otherwise, return 0. The procedure’s input parameter list contains a pointer to the array and the array’s size. Use the PROC directive with a parameter list when declaring the procedure. Preserve all registers (except EAX) that are modified by the procedure. Write a test program that calls FindThrees several times with different arrays.
length: BYTE.data
strCons BYTE “The array contains three consecutive 3.”,0
strNonCon BYTE “The array does not contain three consecutive
3.”,0
arrOne BYTE 1, 2, 3, 2
arrTwo BYTE 3, 3, 5, 7, 3
arrThree BYTE 4, 3, 3, 3, 1, 8.code
main PROC
; calls the procedures
call Clrscr ; clears the screen
; find if the array arrOne contains three consecutive 3
INVOKE FindThrees, ADDR arrOne, LENGTHOF arrOne
.IF eax == 1
mov edx,OFFSET strCons
call WriteString ; writes strCons
call Crlf
.ELSE
mov edx,OFFSET strNonCon
call WriteString ; writes strNonCon
call Crlf
.ENDIF; find if the array arrTwo contains three consecutive 3
INVOKE FindThrees, ADDR arrTwo, LENGTHOF arrTwo
.IF eax == 1
mov edx,OFFSET strCons
call WriteString ; writes strCons
call Crlf
.ELSE
mov edx,OFFSET strNonCon
call WriteString ; writes strNonCon
call Crlf
.ENDIF; find if the array arrThree contains three consecutive
3
INVOKE FindThrees, ADDR arrThree, LENGTHOF arrThree
.IF eax == 1
mov edx,OFFSET strCons
call WriteString ; writes strCons
call Crlf
.ELSE
mov edx,OFFSET strNonCon
call WriteString ; writes strNonCon
call Crlf
.ENDIF
exit
main ENDPFindThrees PROC USES esi ecx,
pArr: PTR BYTE, ; points the array
length: BYTE ; the length of array
; finds if the array contains three consecutive 3 as its
values
; Receives: pointer to array and the length of array
; Returns: EAX = 1 (true) or 0 (false)
mov eax,0 ; initialize EAX = 0
mov esi,pArr ; ESI is the pointer to array
mov ecx,length
sub ecx,2 ; as next 2 elements were observed
L1:
.IF [esi] == 3
.IF [esi+1] == 3
.IF [esi+2] == 3
mov eax,1 ; set EAX = 1
jmp L2
.ENDIF
.ENDIF
.ENDIF
inc esi ;Increment ESI
loop L1
L2:
ret ; returns EAX
FindThrees ENDP
END main
The same program is written is C language also
#include<stdio.h>
#include<stdlib.h>
/* Helper functions to get minimum and maximum in an array */
int getMin(int arr[], int n);
int getMax(int arr[], int n);
/* The function checks if the array elements are consecutive
If elements are consecutive, then returns true, else returns
false */
bool areConsecutive(int arr[], int n)
{
if ( n < 1 )
return false;
/* 1) Get the minimum element in array */
int min = getMin(arr, n);
/* 2) Get the maximum element in array */
int max = getMax(arr, n);
/* 3) max - min + 1 is equal to n, then only check all elements
*/
if (max - min + 1 == n)
{
/* Create a temp array to hold visited flag of all elements.
Note that, calloc is used here so that all values are
initialized
as false */
bool *visited = (bool *) calloc (n, sizeof(bool));
int i;
for (i = 0; i < n; i++)
{
/* If we see an element again, then return false */
if ( visited[arr[i] - min] != false )
return false;
/* If visited first time, then mark the element as visited */
visited[arr[i] - min] = true;
}
/* If all elements occur once, then return true */
return true;
}
return false; // if (max - min + 1 != n)
}
/* UTILITY FUNCTIONS */
int getMin(int arr[], int n)
{
int min = arr[0];
for (int i = 1; i < n; i++)
if (arr[i] < min)
min = arr[i];
return min;
}
int getMax(int arr[], int n)
{
int max = arr[0];
for (int i = 1; i < n; i++)
if (arr[i] > max)
max = arr[i];
return max;
}
/* Driver program to test above functions */
int main()
{
int arr[]= {5, 4, 2, 3, 1, 6};
int n = sizeof(arr)/sizeof(arr[0]);
if(areConsecutive(arr, n) == true)
printf(" Array elements are consecutive ");
else
printf(" Array elements are not consecutive ");
getchar();
return 0;
}
this is assembly language for x-86 processors using microsoft visual studio Create a procedure named FindThrees...
Assembly Language Program Help Write a procedure named CountNearMatches that receives pointers to two arrays of signed doublewords, a parameter that indicates the length of the two arrays, and a parameter that indicates the maximum allowed difference (called diff) between any two matching elements. For each element x(i) in the first array, if the difference between it and the corresponding y(i) in the second array is less than or equal to diff, increment a count. At the end, return a...
We are using the Kip Irvine Assembly Language for x86 Processors. The programming language is Assembly, and we are using visual studio community. Please specify any questions. Directions Declare an array of 60 uninitialized unsigned doubleword values. Create another array of 60 unsigned doublewords, initialized to ‘abcd’. Look at these arrays in the memory window and note how they are stored. (Intel architecture uses little - endian order) ATTEMPT ONLY IF YOU KNOW OTHERWISE I WILL DOWNVOTE.
using assembly language in microwoft visual studio write the following code with procedure with correct number of Fib numbers Your program should detect the largest Fib number that can be calculated. Besides storing the result in an array, print them on the screen.
Assembly Language For x86 Processors 7th edition When you write programs to solve the programming exercises, use multiple procedures when possible. Follow the style and naming conventions used in this book. Use explanatory comments in your programs at the beginning of each procedure and next to nontrivial statements. Random Strings Create a procedure that generates a random string of length L, containing all capital letters. When calling the procedure, pass the value of L in EAX, and pass a pointer...
Class: Assembly Language x 86 Processors I need help reviewing the following topics: 1.) Define a bit, byte, and a nibble. 2.) Define a program, a register, Cache Memory. 3.) What is the meaning of backward compatibility? 4.) List & define x89 processor Modes 5.) What is the processor's operation (Instruction Execution) Cycle ( I am most confused on this topic) 6.) List the processor's Basic registers.
Hi!, having trouble with this one, In this class we use visual studio, C++ language -------------------------------------------------------------- Exercise #10 Pointers - Complete the missing 5 portions of part1 (2 additions) and part2 (3 additions) Part 1 - Using Pointers int largeArray (const int [], int); int largePointer(const int * , int); void fillArray (int * , int howMany); void printArray (const char *,ostream &, const int *, int howMany); const int low = 50; const int high = 90; void main()...