Created
April 10, 2013 00:49
-
-
Save alanyoshida/5350787 to your computer and use it in GitHub Desktop.
Calcula o quadrado do numero em Assembly em AT&T.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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