Question: The C prototype for the first procedure is shown below. void removeChar(char* string, char rmvChar, int stringLength); removeChar will remove a designated character, rmvChar, from
The C prototype for the first procedure is shown below.
void removeChar(char* string, char rmvChar, int stringLength);
removeChar will remove a designated character, rmvChar, from the string that is passed to the procedure. For example, suppose we had the following C code:
char string[] = "abcdefg"; removeChar(string, 'c'); printf("string = %s ", string); The result should be "string = abdefg" being printed.
You should use one or more string primitive instructions in your solution. You can assume the string only has one character that you need to remove. Remember that you have to accommodate the terminating character in C strings. The string length given to your procedure does not count the terminating character.
The C prototype for the second procedure would look like the following:
void multiplyDwordArrays(int* array1, int* array2, int count);
Here are the things multiplyDwordArrays should do:
Multiply each element of array A by each element of array B and store the results in array A.
Use one or more string primitive instructions.
Use signed arithmetic since signed numbers are being passed.
It does not have to detect or handle overflows.
Please note that the C code will pass the addresses of strings or arrays to the assembly functions, not the entire array. In other words, the arrays are passed by reference.
The following source file contains the C code you will use to call the assembly procedures. You may modify the code for testing purposes.
#include
// C prototypes for the functions written in assembly language void removeChar(char* string, char rmvChar, int stringLength); void multiplyDwordArrays(int* array1, int* array2, int count);
// Main ------------------------------------------------------------------- int main() { char string[] = "abcdefg"; int array1[] = { 1, -2, 3, 4, 5 }; int array2[] = { 1, 2, 3, -4, 5 }; int arraySize = sizeof(array1) / sizeof(int);
removeChar(string, 'c', strlen(string));
multiplyDwordArrays(array1, array2, arraySize);
return 0; }
; Do not need to include the C library functions since we are linking with C.
; Directives (only one needed) .model flat,C
; Declare some standard C functions as externals extern printf:PROC extern putchar:PROC extern getchar:PROC extern scanf:PROC
; C calling conventions: ; EBP, EBX, ESI, EDI should not be modified in a function call (non-volatile) ; EAX, ECX, EDX can be modified (volatile)
;--------------------- .data ; Put your statically defined data here
;----------------------
; You can use the following symbolic constants to make ; accessing parameters easier parameter1 EQU [ebp+8] parameter2 EQU [ebp+12] parameter3 EQU [ebp+16] local1 EQU [ebp-4] local2 EQU [ebp-8]
.code ;----------------------------------------------------- ; Description: What does your procedure do? ; Receives: What does it receive? ; Returns: What does it return? ;----------------------------------------------------- my_proc PROC ; Prolog push ebp mov ebp, esp ;sub esp, 4 ; Allocate local var(s) ;push esi ; Have to save registers that are non-volatile ;push edi ;push ebx ; Epilog ;pop ebx ;pop edi ;pop esi mov esp, ebp pop ebp ret my_proc ENDP
END
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
