0

I have the following assembly program which compiles and runs correctly in QTSpim and displays the correct result in the QTSspim console. However, I wish to observe the data segment in PCSpim-cache but it does not compile correctly and display the correct result in the out (it displays a 0 in each position) I should say the program computes the Kronecker product of the two vectors specified in the data portion of the file. Here is my code:

## 4/20/16
## Lab 5 

.data 0x10000480
str1: .asciiz "This is lab 5, A2: \n"
str2: .asciiz "C = "
str3: .asciiz ", "

def: .word 4 

ArrayA: 
.word 1, 2, 3
ArrayB: 
.word 8, 7, 6
arrayC: 
.space 100

.text

main:

## Print str1
li $v0, 4 
la $a0, str1
syscall

## Print str2
li $v0, 4
la $a0, str2 
syscall

la $s0, ArrayB         # Load address of B into $s0
la $s1, ArrayA         # Load address of A into $s1 
#la $s2, ArrayC         # Load address of C into $s1

li $t0, 0         # initialize iterator 

li $s3, 3         # 3 count 



Kproduct:
    li $t5, 1                   # Load value of A
    li $t1, 0                   # initialize second iterator 
    beq $t0, $s3, End 
    lw $t2, ($s0)
    addi $t0, $t0, 1            # Increment overall iterator 
    addi $s0, $s0, 4 


    j Kloop




Kloop:
        beq $t1, $s3, Kproduct  # When 3 calculations are made 
        mul $t4, $t2, $t5       # A*B
        addi $t5, $t5, 1        # increment A
        addi $t1, $t1, 1        # increment iterator 

        ## Print next value 
        li $v0, 1
        move $a0, $t4 
        syscall               

        ## Print space 
        li $v0, 4
        la $a0, str3 
        syscall 

        j Kloop 
End: 
    ## End 
    li $v0, 10 
    syscall

If someone could shed light on why it does not work in both compilers it would be greatly appreciated. I am including a link to PCSpim cache, which I was given by my lab instructor to use. I hope you are familiar with QTSpim.

PCSpim-cache link: http://www.disca.upv.es/spetit/spim.htm

Daniel
  • 66
  • 1
  • 9
  • _"it does not compile correctly ... it displays a 0 in each position"_ If it doesn't compile correctly, how are you able to run it in order to have it display anything at all? – Michael Apr 22 '16 at 05:36
  • It runs and displays 0 instead of the kronecker product in PCSpim-cache and correctly in QTSpim as you can see the code shows and how my post described the output. I believe I was clear. – Daniel Apr 22 '16 at 16:02
  • Then you should remove _"it does not compile correctly"_ from your question, because if you are able to run the program it presumably compiled without errors. A compile-time error and a run-time error are two different things. Now, if you get any compile-time _warnings_ you should probably add those to your question. – Michael Apr 22 '16 at 16:33

0 Answers0