#include <stdio.h>
#include <string.h>
void lowerascii(char *str1, char *str2, char *returnstring)
{
//find the size of the string
int stringsize = -1;
int sizecounter = 100;
printf("The entered string is: %s\n", str1);
printf("The entered string is: %s\n", str2);
__asm__(
"movl $100, %%ecx\n\t" //used as a counter to find the string size
"movl %1, %%edi\n\t"
"movl $0, %%eax\n\t"
"repne scasb\n\t"
"cld\n\t"
"subl %3, %%ecx\n\t"
"not %%ecx\n\t"
"movl %%ecx, %0\n\t"
:"=r" (stringsize)
:"r" (str1), "r" (str2), "b" (sizecounter)
);
printf("The length of the lists are: %i\n", stringsize);
int result1 = 0;
int result2 = 0;
//int result3 = 0;
//get new string
__asm__(
"movq (%1), %%mm0\n\t"
"movq (%1), %%mm1\n\t"
"movq (%1), %%mm2\n\t"
"movq (%1), %%mm3\n\t"
"movq (%2), %%mm4\n\t"
"movq (%2), %%mm5\n\t"
"movq (%2), %%mm6\n\t"
"movq (%2), %%mm7\n\t"
"begin:\n\t"
"cmpl $0, %%eax\n\t"
"je end\n\t"
//comparions for the string
"pcmpeqb %%mm0, %%mm4\n\t"
"movd %%mm4, %%ebx\n\t"
"pand %%mm0, %%mm4\n\t"
"cmpl $0, %%ebx\n\t"
"jne addtostring1\n\t"
"pcmpgtb %%mm0, %%mm5\n\t"
"movd %%mm5, %%ebx\n\t"
"pand %%mm0, %%mm5\n\t"
"cmpl $0, %%ebx\n\t"
"jne addtostring2\n\t"
"pcmpgtb %%mm6, %%mm0\n\t"
"movd %%mm6, %%ebx\n\t"
"pand %%mm6, %%mm0\n\t"
"cmpl $0, %%ebx\n\t"
"jne addtostring3\n\t"
//add to the new string
"addtostring1:\n\t"
"movq %%mm4, (%0)\n\t"
"dec %%eax\n\t"
"jmp begin\n\t"
"addtostring2:\n\t"
"movq %%mm5, (%0)\n\t"
"dec %%eax\n\t"
"jmp begin\n\t"
"addtostring3:\n\t"
"movq %%mm0, (%0)\n\t"
"dec %%eax\n\t"
"jmp begin\n\t"
"end:\n\t"
:"=r" (returnstring)
:"r" (str1), "r" (str2), "a" (stringsize)
//"emms\n\t"
);
printf("The new string is: %s\n", returnstring);
printf("\n");
}
#include <stdio.h>
#include <string.h>
void lowerascii(char *str1, char *str2, char *returnstring);
int main()
{
//char string1[50] = "HellO";
//char string2[50] = "hElLO";
//char newstring[50];
char string1[100] = "HellO";
char string2[100] = "HElLo";
char newstring[100]= "aaaaa";
lowerascii(string1, string2, newstring);
//printf("The newstring is: ");
//printf("%s\n",newstring);
return 0;
}