How to solve a problem to work with two arrays in asm?

Good day!
I need to write a program in which I have an array of 16(32) bytes. Need from c++ to move the array to the assembler box, where you can move this array to another array all the elements that equal to the sum of the next. In the assembler the maximum use of the double word. That is, the registers e*x you can't take. Can anyone suggest where to find material on this topic, or to offer sample code to solve this problem? I tried to find something on the Internet on this subject, but unfortunately found nothing :(
April 4th 20 at 13:10
1 answer
April 4th 20 at 13:12
Solution
Need from c++ to move the array to the assembler box, where you can move this array to another array all the elements that equal to the sum of the next.
That is, the registers e*x you can't take. Can anyone suggest where to find material on this topic, or to offer sample code to solve this problem?

You can write this code so that it will not use any specific registers explicitly. Specific registers will be inlined by the compiler. For example (gcc):
#include <stdint.h>

void f(void)
{
 uint32_t a[16] = {1, 2, 3, 1, 5, 4, -1, }, b[16] = {0};
 void *a1, *b1;
 uint32_t tmp, cnt = 14;

 asm (
 "lea %[a] %[a1]\n\t"
 "lea %[b] %[b1]\n"
"1:\n\t"
 "mov (%[a1]), %[tmp]\n\t"
 "add 8(%[a1]), %[tmp]\n\t"
 "cmp 4(%[a1]), %[tmp]\n\t"
 "jne 2f\n\t"
 "mov %[tmp], (%[b1])\n\t"
 "add $4, %[b1]\n"
"2:\n\t"
 "add $4, %[a1]\n\t"
 "dec %[cnt]\n\t"
 "jnz 1b\n\t"
 : [cnt] "=&r" (cnt), [tmp] "=&r" (tmp),
 [a1] "=&r" (a1), [b1] "=&r" (b1),
 [b] "=m" (b)
 [a] m (a));
}
but you can explicitly use any of the registers, and then are we not taught to do, unfortunately( - Zoila.Lowe84 commented on April 4th 20 at 13:15
are we not taught to do, unfortunately

@Zoila.Lowe84, and in vain, because to do so in assembler inserts -- good and useful. - amos.Stark4 commented on April 4th 20 at 13:18
@amos.Stark4, I'm not arguing, but what to do if require( - Zoila.Lowe84 commented on April 4th 20 at 13:21

Find more questions by tags C++Assembler