×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

prob to resolv in Assembly IA32 for GAS

prob to resolv in Assembly IA32 for GAS

prob to resolv in Assembly IA32 for GAS

(OP)
Hi!

I need to do, in IA32 Assembly for GAS, a program capable of
sort a vector of integers, and calculate the mean and median values of the vector.
The vector integers is initialized and has a fixed size of 20 elements, and the output data be made to the monitor.

I have an example, but does't work.

Can any body help me please??

»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»

"1 selectionSort :
2 beq $a1 , $zero , fimA # se array é vazio , retorna
3
4 # Itera por todos os elementos do array. Otimização : não iterar
indexando o array com o i, e sim iterar pelos endereços dos elementos
do array.
5 sll $t0 , $a1 , 2 # $t0 = tamanho * 4
6 add $t0 , $t0 , $a0 # $t0 = endereço de array [ tamanho ]
7
8 move $t7 , $a0 # endereço de array [i] = endereço de array [0]
9
10 loopA :
11 move $t9 , $t7 # endereço de array [min] = endereço de array [i
]
12 lw $t4 , 0( $t9) # $t4 = array [ min]
13
14 # Procura pelo endereço do menor elemento , a partir do elemento seguinte
do cursor. Otimização usa a mesma otimização do loop externo : não
indexar com o j, e sim iterar pelos endereços.
15 addi $t8 , $t7 , 4 # endereço de array [j] = endereço de array [i
+1]
16 beq $t8 , $t0 , fimB # se endereço de array [j] == endereço de array
[ tamanho ], então não procura pois esse é o último elemento
17
18 loopB :
19 lw $t3 , 0( $t8) # $t3 = array [j]
20 slt $t5 , $t3 , $t4 # $t5 = array [j] < array [min ]
21 beq $t5 , $zero , fimIf # se array [j] >= array [min], continua o
loop
22
23 # Atualiza registradores que contém endereço e conteúdo de array [min]
24 move $t9 , $t8 # endereço de array [j] = endereço de array [min
]
25 lw $t4 , 0( $t9) # $t4 = array [ min]
26
27 fimIf :
28 addi $t8 , $t8 , 4 # incrementa endereço de array [j]
29 bne $t8 , $t0 , loopB # se endereço de array [j] != endereço de array
[ tamanho ], continua procurando menor
30
31 fimB :
32 # Troca o elemento atual do cursor com o menor elemento encontrado
33 lw $t6 , 0( $t7) # auxiliar = array [i]
34 sw $t4 , 0( $t7) # array [i] = array [min]
35 sw $t6 , 0( $t9) # array [min ] = auxiliar
36
37 addi $t7 , $t7 , 4 # incrementa endereço de array [i]
38 bne $t7 , $t0 , loopA # continua iterando pelos elementos se
endereço de array [i] != endereço de array [ tamanho ]
39
40 fimA :
41 jr $ra # Retorna. Neste momento , o array que está em
$a0 está ordenado
"


«««««««««««««««««««««««


Thkx!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close