Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Potrebna provera sintakse za MIPS32

[es] :: Asembler :: Potrebna provera sintakse za MIPS32

[ Pregleda: 2518 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

JagodaV

Član broj: 86247
Poruke: 26
*.migcomputers.co.yu.

Jabber: jagoda@elitesecurity.org


Profil

icon Potrebna provera sintakse za MIPS3208.11.2006. u 19:01 - pre 211 meseci
Imam kod izlistan ispod. Moj zadatak je bio da napravim proceduru Sums sto sam uradila kao sto je u datom kodu. Ostatak koda je dat (glavna main procedura koja poziva Sums). Medjutim dobijam gresku (mipster - Start with SPIM):

Citat:
SPIM Version 6.0 of July 21, 1997
Copyright 1990-1997 by James R. Larus ([email protected]).
All Rights Reserved.
DOS and Windows ports by David A. Carley ([email protected]).
Copyright 1997 by Morgan Kaufmann Publishers, Inc.
See the file README for a full copyright notice.
Loaded: ./trap.han
Exception occurred at PC=0x00400028
Bad address in data/stack read: 0x00000004
Exception 7 [Bad address in data/stack read] occurred and ignored


Evo i koda:
Code:

.data
MainNumInts:
       .word  12
MainIntegers:
       .word  442
       .word  142
       .word   72
       .word   87
       .word   -9
       .word    2
       .word  -42
       .word  -42
       .word  -92
       .word   62
       .word  -42
       .word  -88
       .word    0
MainNewline:
       .asciiz "\n"
MainSumString:
       .asciiz "Partial sum: "

.text
main:
       # Function prologue -- even main has one
       subu  $sp, $sp, 24      # allocate stack space
                               # default of 24 here
       sw    $fp, 0($sp)       # save caller's frame pointer
       sw    $ra, 4;($sp)       # save return address
       addiu $fp, $sp, 24      # setup main's frame pointer

       #  for (i = 0; i < MainNumInts; i++) {
       #     sum = getSum(&MainIntegers[i])
       #  }
       # $s0 = MainNumInts, the # of elements in the array
       la    $s0, MainNumInts  # $s0 = &MainNumInts
       lw    $s0, 0($s0)
       la    $s6, MainIntegers # $s6 = &MainIntegers[0]
       addi  $s1, $zero, 0     # $s1 = i = 0

MainLoopBegin:
       slt   $s2, $s1, $s0     # $s2 = i < MainNumInts
       beq   $s2, $zero, MainLoopEnd

       sll   $s3, $s1, 2       # $s3 = 4 * i
       add   $s4, $s6, $s3     # $s4 = &MainIntegers[i]

       # Startup Sequence
       addi  $a0, $s4, 0       # $a0 = &MainIntegers[i]
       jal   Sums

       # Cleanup Sequence
       addi  $s5, $v0, 0       # $s5 = partial sum

       # Print sum
       la    $a0, MainSumString
       li    $v0, 4
       syscall
       addi  $a0, $s5, 0       # $a0 = partial sum
       li    $v0, 1
       syscall
       la    $a0, MainNewline
       li    $v0, 4
       syscall

       addi  $s1, $s1, 1       # i++
       j     MainLoopBegin
MainLoopEnd:
MainDone:
       # Epilogue for main -- restore stack & frame and return
       lw    $ra, 4($sp)       # get return address from stack
       lw    $fp, 0($sp)       # restore the caller's frame pointer
       addiu $sp, $sp, 24      # restore the caller's stack pointer
       jr    $ra               # return to caller

# Your code goes below this line

.data
msg1:
    .asciiz "Sums function used  "
msg2:
    .asciiz "integers to compute the sum.\n"

Sums:
      # Function prologue
      subu  $sp, $sp, 24    # allocate stack space -- default of 24 here
      sw    $fp, 0($sp)     # save caller's frame pointer
      sw    $ra, 4($sp)     # save return address
      sw    $a0, 8($sp)     # save parameter value
      addiu $fp, $sp, 24    # setup zap1's frame pointer

       add $t2, $zero, $zero
       add $t3, $zero, $zero
       li $t1, 0($a0)
sumLoopBegin:
       beq $t1, $zero, sumsLoopEnd
       add $t2, $t2, $t1
       add $t3, $t3, 1
       add $a0, $a0, 4
       li $t1, 0($a0)
       j sumLoopBegin
sumsLoopEnd:
       la    $a0, msg1
      li    $v0, 4
      syscall
       la    $a0, $t3
      li    $v0, 1
      syscall
       la    $a0, msg2
      li    $v0, 4
      syscall
       add $v0, $t2, $zero

# Function epilogue -- restore stack & frame pointers and return
      lw    $a0, 8($sp)     # restore original value of $a0 for caller
      lw    $ra, 4($sp)     # get return address from stack
      lw    $fp, 0($sp)     # restore the caller's frame pointer
      addiu $sp, $sp, 24    # restore the caller's stack pointer
      jr    $ra             # return to caller's code


[Ovu poruku je menjao JagodaV dana 08.11.2006. u 20:19 GMT+1]
FBzP

 
Odgovor na temu

JagodaV

Član broj: 86247
Poruke: 26
*.tcsn.qwest.net.

Jabber: jagoda@elitesecurity.org


Profil

icon Re: Potrebna provera sintakse za MIPS3209.11.2006. u 03:25 - pre 211 meseci
Reseno :-)
FBzP

 
Odgovor na temu

[es] :: Asembler :: Potrebna provera sintakse za MIPS32

[ Pregleda: 2518 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.