Digitalize de stdin e imprima para stdout usando montagem embutida no gcc
Como ler do stdin e gravar no stdout no assembly inline gcc, assim como fazemos no NASM:
_start:
mov ecx, buffer ;buffer is a data word initialised 0h in section .data
mov edx, 03
mov eax, 03 ;read
mov ebx, 00 ;stdin
int 0x80
;Output the number entered
mov eax, 04 ;write
mov ebx, 01 ;stdout
int 0x80
Tentei ler a partir de stdin no assembly embutido e, em seguida, atribua a entrada para x:
#include<stdio.h>
int x;
int main()
{
asm(" movl $5, %%edx \n\t" "
movl $0, %%ebx \n\t" "
movl $3, %%eax \n\t" "
int $0x80 \n\t "
mov %%ecx,x"
::: "%eax", "%ebx", "%ecx", "%edx");
printf("%d",x);
return 0;
}
No entanto, isso não ocorre.
syscall de dentro da montagem embutida do GCC
Este link contém um código capaz de imprimir apenas um único caractere no stdout.