0

我已经创建了 Julia 迭代,但我无法将其与 MARS 中的位图显示集成。它应该只接受 a 和 b 的输入,并使用嵌套循环来迭代函数 256 次。这是我到目前为止所拥有的:

    .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:
4

1 回答 1

1

看起来在您的 Julia 循环中,您缺少退出循环的条件。

于 2014-03-13T02:26:46.083 回答