Alex Larose

Generation

generate functionTue, 07 Mar 2023

Write a C callable assembler function named "count" that counts the number of times a user-entered character appears in a user-entered string. The function should take two arguments: a pointer to the string and the character to be counted. Use a stack frame and return the count in %eax. Store all data as 32-bit quantities.

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

Questions about programming?Chat with your personal AI assistant