Jump to content
  • Revista PROGRAMAR: Já está disponível a edição #60 da revista programar. Faz já o download aqui!

Sign in to follow this  
costricardo

Bubble sort ajuda codigo

Recommended Posts

costricardo

Estou a elaborar o Bubble sort mas o codigo está a dar erro .... alguem que ajude

/*void bubble_as2 (int *x, int n);*/

.globl bubble_as2

/* assembler utilizado gas (x86 - Linux) */

bubble_as2:

pushl %ebp 

movl %esp, %ebp /* copia o qu esta no topo da pilha para a base da pilha */

movl 12(%ebp), %eax  /* tamanho -> %eax */

movl 8(%ebp), %ecx  /* início do vetor -> %ecx */

movl $4, %ebx

dec %eax

mul %ebx

addl %eax, %ecx /* %ecx aponta p/ o último do elemento do vetor */

pushl %ecx

_bubble_as2_l1:

movl $0, %edx

movl 8(%ebp), %ebx

movl %ebx, %eax

addl $4, %eax

_bubble_as2_l2:

cmp %eax, %ecx

jl _bubble_as2_l1_end

movl (%ebx), %ecx

cmp (%eax), %ecx

jl _bubble_as2_l2_end

/* troca */

movl (%eax), %edx

movl %edx, (%ebx)

movl %ecx, (%eax)

movl $1, %edx

_bubble_as2_l2_end:

movl %eax, %ebx

addl $4, %eax

movl (%esp), %ecx

jmp _bubble_as2_l2

_bubble_as2_l1_end:

cmp $0, %edx

je _bubble_as2_fim

popl %ecx

subl $4, %ecx

pushl %ecx

jmp _bubble_as2_l1

_bubble_as2_fim:

leave

ret


I´m a Geek and you?www.tecnologias.in

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.