Announcement

Collapse
No announcement yet.

Vettori - Max e Index

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Vettori - Max e Index

    Code:
    #vet a 10 ele
    #
    # max = -1
    # max_index = -1
    # for (i=0,i<10,i++)
    #                if (a[i]> max && a[i]%2==0)
    #                                max = a[i]
    #                                max_index = i
    #
    #$1=i
    #$2= spiaz i
    #$3= max
    #$4= max_index
    #$5= a[i]
    #$6=slti, i<10, slt max < a[i], and a[i] e 1
    %veta = 1100
    %start = 1400
    
                    addi $3,$0,-1 # init max -1
                    addi $4,$0,-1 # init max_index -1
                    add $1,$0,$0 # i=0
                    add $2,$1,$1 # spiaz i
                    add $2,$2,$2
    inizio_for:     slti $6,$1,10
                    beq $6,$0,fine_for
                    addi $5,$2,1100 #indirizzo di a[i]
                    lw $5,0($5) # a[i] in $5
                    slt $6,$3,$5 #max < a[i]?
                    beq $6,$0,fine_if
                    andi $6,$5,1 # and a[i] e 1
                    bne $6,$0, fine_if
                    add $3,$0,$5
                    add $4,$0,$1
    fine_if:        addi $1,$1,1 # i=i+1
                    add $2,$1,$1 # spiaz i
                    add $2,$2,$2
                    j inizio_for
    fine_for:       add $0,$0,$0
    | VFX Artist, C++ Programmer, HW Overclocker | Web: xgiovio.com Email: xgiovio@gmail.com Twitter: @xgiovio
Working...
X

Google Profile


My name is Giovanni Di Grezia, but people call me xgiovio.

Here is my homepage:.

I'm a VFX Artist and Software Developer.

Giovanni Di Grezia