2014-03-12 35 views
0

我已經創建了Julia迭代,但是我在將它與MARS中的位圖顯示集成時遇到了問題。它應該只接受a和b的輸入,並使用嵌套循環迭代函數256次。這是我到目前爲止:MIPS Julia集與位圖顯示相連

.data 
str1: .asciiz "Enter the value of a:" #Declaring all the string variables that will print to the screen. 
str2: .asciiz "Enter the value of b:" 

height: .float 256 #Create the height and width constants to be used. 
width: .float 256 
const: .float -1.5 

    .text 
main: 
    li $v0, 4  #Load the appropriate system call code into register $v0. 
    la $a0, str1  #Load address of string to be printed into $a0. 
    syscall   #Call OS to perform print operation. 
    li $v0, 6  #Load the system call code for reading a float. 
    syscall  #Call OS to read the user input. 
    mov.s $f1, $f0 #Move the user inputted float into register $f12. 

    li $v0, 4 
    la $a0, str2 
    syscall 
    li $v0, 6 
    syscall 
    mov.s $f2, $f0 

    j Loop  #Jump to Loop. 

    li $v0, 10  #Load the appropriate system call code into register $v0. 
    syscall   #Call OS to perform the exit operation. 

Loop: 
    addi $s0, $s0, 256  #Set number of iterations to 256. 
    blt $s1, $s0, Loop2  #If i < 256 then go to Loop2. 
    j exit    #If i >= 256 then jump to exit. 

Loop2: 
    beq $s2, $s0, exit  #If j = 256 then exit 

    lwc1 $f20, const($0)  #Load the constant -1.5 in register $f20. 
    lwc1 $f18, width($0)  #Load the constant width in register $f18. 
    lwc1 $f18, height($0)  #Load the constant height in the register $f18. 

    #div.s $s2, $s1, $t0  #Divide pixel i by with and store into register $s2. 
    #ac1 dd $s3, $s2, $s2  #2*(i/w). 
    #add $s3, $s3, $s2  #3*(i/w). 

Julia: 
    mul.s $f30, $f8, $f8  #Register $f30 gets x^2. 
    mul.s $f28, $f6, $f6  #Register $f28 gets y^2. 
    sub.s $f28, $f30, $f28  #Register $f28 gets x^2 - y^2. 
    add.s $f28, $f28, $f1  #Register $f28 gets (x^2 - y^2) + a. 

    mul.s $f26, $f8, $f6  #Register $f26 gets xy. 
    add.s $f26, $f26, $f26  #Register $f26 gets 2xy. 
    add.s $f26, $f26, $f2  #Register $f26 gets 2xy + b. 

    mov.s $f8, $f28   #x = (x^2 - y^2) + a. 
    mov.s $f6, $f26   #y = 2xy + b. 

    addi $s1, $s1, 1  #Increment the number of iterations. 

    j Julia    #Go through loop again. 
exit: 

回答

1

它看起來像你的朱莉婭循環,你錯過了一個條件退出循環。