Well let me start off by saying memset is the proper way to initialize an array but if you want to see AT & T inline asm then you really should check the many docs on the internet..Here's my very simple version..Note its for a 64 bit Intel/AMD system.
include <stdio.h>
#define SIZE 10
int test[SIZE];
int main()
{
int i = 0;
for (i = 0; i < SIZE; ++i)
test[i] = i + 3;
for (i = 0; i < SIZE; ++i)
fprintf(stdout, "ans->%d\n", test[i]);
__asm__
(
"pushq %rdi\n\t"
"pushq %rax\n\t"
"xorq %rdi, %rdi\n\t"
"call 1f\n\t"
"1:\n\t"
"popq %rax\n\t"
"addq $5, %rax\n\t"
"cmpq $9, %rdi\n\t"
"je 2f\n\t"
"movq $0, test(, %rdi, 4)\n\t"
"incq %rdi\n\t"
"jmp *%rax\n\t"
"2:\n\t"
"popq %rax\n\t"
"popq %rdi\n\t"
);
for (i = 0; i < SIZE; ++i)
fprintf(stdout, "ans->%d\n", test[i]);
return 0;
}
Output on my system
ans->3
ans->4
ans->5
ans->6
ans->7
ans->8
ans->9
ans->10
ans->11
ans->12
ans->0
ans->0
ans->0
ans->0
ans->0
ans->0
ans->0
ans->0
ans->0
ans->0