Alex Larose

Generation

linuxWed, 08 Mar 2023

. Write a C callable assembler function that counts the number of characters in a string. The function should work for any string and character. The address of the string and character to be counted are passed as arguments according to the C function prototype: int count (char *string, char c); Since there are input arguments, your assembly function should use a stack frame. It should return the count to the calling C program in %eax. Use 32-bit quantities for all data.

int count(char*, char); int count(char* string, char c){ int i = 0; while(*(string + i) != '\0'){ if(*(string + i) == c){ break; } i++; } return i; }

Questions about programming?Chat with your personal AI assistant