Skip to content

Instantly share code, notes, and snippets.

@alanyoshida
Created April 10, 2013 00:49
Show Gist options
  • Save alanyoshida/5350787 to your computer and use it in GitHub Desktop.
Save alanyoshida/5350787 to your computer and use it in GitHub Desktop.
Calcula o quadrado do numero em Assembly em AT&T.
.section .data
.section .text
.globl _start
.globl square
_start:
pushl $5
call square
addl $4, %esp
movl %eax, %ebx
movl $1, %eax
int $0x80
.type square,@function
square:
pushl %ebp # guarda ebp na stack
movl %esp, %ebp # joga o esp para o ebp
movl 8(%ebp), %eax # armazena primeiro param no eax
imull %eax,%eax # eax multiplicado por eax e guarda em eax
movl %ebp, %esp
popl %ebp
ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment