Created
April 10, 2013 00:57
-
-
Save alanyoshida/5350825 to your computer and use it in GitHub Desktop.
De tres listas descobrir qual o maior numero em Assembly 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 | |
data_items1: .long 3,67,34,222,45,75,54,34,44,33,22,11,66,0 | |
data_items2: .long 20,40,60,70,24,65,17,23,75,35,14,34,29,0 | |
data_items3: .long 46,57,76,14,13,58,34,49,24,63,25,48,64,0 | |
.section .text | |
.globl _start | |
.globl max | |
_start: | |
# primeiro data_items | |
pushl $data_items1 | |
call max | |
addl $4,%esp | |
pushl %eax | |
# segundo data_items | |
pushl $data_items2 | |
call max | |
addl $4, %esp | |
pushl %eax | |
# terceiro data_items | |
pushl $data_items3 | |
call max | |
addl $4, %esp | |
pushl %eax | |
#maior do terceiro data items | |
popl %ebx | |
#maior do segundo data items | |
popl %ecx | |
#maior do primeiro data items | |
popl %edx | |
# eax armazena o maior numero | |
# primeiro parametro e maior | |
movl %edx,%eax | |
# comparo | |
comp1: | |
cmpl %eax,%ebx | |
jg armazena1 | |
#comparo com o segundo | |
comp2: | |
cmpl %eax,%ecx | |
jg armazena2 | |
jmp fim | |
armazena1: | |
movl %ebx,%eax | |
jmp comp2 | |
armazena2: | |
movl %ecx,%eax | |
fim: | |
movl %eax,%ebx | |
movl $1,%eax | |
int $0x80 | |
.type max,@function | |
max: | |
pushl %ebp | |
movl %esp,%ebp | |
movl 8(%ebp),%ecx | |
#pushl %ecx | |
movl $0,%edi | |
movl 0(%ecx,%edi,4),%eax | |
movl %eax,%ebx | |
start_loop: | |
cmpl $0,%eax | |
je loop_exit | |
incl %edi | |
movl 0(%ecx,%edi,4),%eax | |
cmpl %ebx,%eax | |
jle start_loop | |
movl %eax,%ebx | |
jmp start_loop | |
loop_exit: | |
movl %ebx,%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