-2
내가 작성한 코드는 두 번째 루프 이후부터 줄 바꿈과 'totalmin'문자열이 인쇄되지 않습니다. 누군가가이 문제를 해결하는 방법을 알려주시겠습니까?루프 내에서 공백과 새 줄 인쇄 문제
#a1 is the minvalue base address for the minterms
#a2 holds value 1
#a3 holds minvalue[i]
#t0 is the counter
#t1 is the counter*4
#t2 holds the value of bit0[i]
#t3 holds the value of bit1[i]
#t4 holds the value of bit2[i]
#t5 holds the value of bit3[i]
#t6 holds the value of the compliment of bit0[i]....second use uses t6 as the product of bit0^bit1'
#t7 holds the value of bit2^bit3.... second use uses t7 as the product of (bit2^bit3)xor(bit1^bit0')
#t9 holds the min number
#s0 is the minvalue base address+(counter*4)
#s1 is the bit0 base address
#s2 is the bit1 base address
#s3 is the bit2 base address
#s4 is the bit3 base address
#s5 is the bit0 base address+(counter*4)
#s6 is the bit1 base address+(counter*4)
#s7 is the bit2 base address+(counter*4)
#t8 is the bit3 base address+(counter*4)
.data
bit0: .word 0,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1 #array which holds values of bit zero
bit1: .word 0,0,1,1,0,0,1,1,0,0,1,1,0,0,1,1 #array which holds values of bit one
bit2: .word 0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1 #array which holds values of bit two
bit3: .word 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1 #array which holds values of bit three
minvalue: .word 0 #array which holds the min term for each value
space: .asciiz " " #creates a space when printing
newline: .asciiz "\n" #creates a new line when printing
totalmin: .asciiz "the number of Minterms in F is: "
.text
la $a1, minvalue #base address for minterms
la $s1, bit0 #base address for bit0
la $s2, bit1 #base address for bit1
la $s3, bit2 #base address for bit2
la $s4, bit3 #base address for bit3
li $t0, 0 #t0 is the counter which is set to 0
li $a2, 1 #a2 holds value 1
li $t9, 0 #min number is set to 0
loop:
sll $t1, $t0, 2 #multiplies the current value of t0 by 4 or t1=i*4
add $s0, $a1, $t1 #adds the minvalue base address by 4 each loop or s0= minvbase+(i*4)
add $s5, $s1, $t1 #adds the bit0 base address by 4 each loop or s5= bit0base+(i*4)
add $s6, $s2, $t1 #adds the bit1 base address by 4 each loop or s6= bit1base+(i*4)
add $s7, $s3, $t1 #adds the bit2 base address by 4 each loop or s7= bit2base+(i*4)
add $t8, $s4, $t1 #adds the bit3 base address by 4 each loop or t8=bit3base+(i*4)
lw $t2, 0($s5) #t2 holds the value of bit0[i]
lw $t3, 0($s6) #t3 holds the value of bit1[i]
lw $t4, 0($s7) #t4 holds the value of bit2[i]
lw $t5, 0($t8) #t5 holds the value of bit3[i]
not $t6, $t2 #t6 holds the value of the compliment of bit0[i]
and $t6, $t6, $t3 #t6 holds the value of bit1^bit0'
and $t7, $t4, $t5 #t7 holds the value of bit2^bit3
xor $t7, $t7, $t6 #t7 holds the value of (bit2^bit3)xor(bit1^bit0')
sw $zero, 0($s0) #minterm[i] is intially set to zero
bne $t7, 0, minterm1 #if t7 is 1 then jump to minterm1
print:
lw $a3, 0($s0) #a3 holds the value of minvalue[i]
li $v0, 1
move $a0, $t5
syscall
li $v0, 1
move $a0, $t4
syscall
li $v0, 1
move $a0, $t3
syscall
li $v0, 1
move $a0, $t2
syscall
li $v0, 4
la $a0, space
syscall
li $v0, 1
move $a0, $a3
syscall
li $v0, 4
la $a0, newline
syscall
addi $t0, $t0, 1 #increment counter or i++
bge $t0, 16, exit #if t0 >= 16 jump to exit
j loop #else jump to loop
minterm1:
sw $a2, 0($s0) #rewrites the minterm[i] from zero to 1
addi $t9, $t9, 1 #min number= min number+1
j print
exit:
li $v0, 4
la $a0, totalmin
syscall
li $v0, 1
move $a0, $t9
syscall
li $v0, 10
syscall
출력 :
(공백)없이 인쇄 값IM 화성 4.4를 사용하여 정확하고 또한 4.3의 코드를 사용하지만, 출력이 동일한 코드 때문에 루프 정확