darklord
darklord

Reputation: 13

MIPS CODE mathematical expression with OR and AND symbols

Can some one help me with how to use OR and AND in MIPS code In this equation 𝐴[25] = [(𝑎 ∗ c/512 + 𝑙 ∗ 𝑏) |16]&[𝐴|𝐵 ∗ c/16 − 𝐵[18]]

(𝑎 ∗ c/512 + 𝑙 ∗ 𝑏) |16 OR used here

𝐴|𝐵 OR used here. and AND used in between two expression.

Kindly help! Because I have done almost half part and half remaining.


print: .asciiz "  𝐴[25] = [(𝑎 ∗ c/512 + 𝑙 ∗ 𝑏) |16]&[𝐴|𝐵 ∗ c/16 − 𝐵[18]] =   "
space: .asciiz "  "
A: .word 12 2 3 4 5 6 7 7 8 3 6 2 4 1 5 6 3 7 4 8 5 4 3 2 1
B: .word 23 2 3 4 5 6 7 7 8 3 6 2 4 1 5 6 3 7 
a: .word 4
b: .word 2
l: .word 6
c: .word 1024


.text

main:
#get the integer input n from user
    lw $t0, a # $t0 = a = 4
    lw $t1, b # $t1 = b = 2
    lw $t2, l # $t2 = l = 6
    lw $t3, c # $t3 = c = 512
    la $s5, A # $s5 = A[25] = .....total 25 indexes data
    la $s7, B # $s7 = B[18] = .....total 18 indexes data
    lw $t4, 96($s5) # $t4 = A[25] = 1
    lw $t5, 68($s7) # $t5 = B[18] = 7```
    
    srl $t6,$t3, 9  # $t6 = c/512 = 1
    #showing c/512 = 1
    #li $v0, 1
    #move $a0, $t6
    #add $t7, $t7, $t0
    sll $t7, $t0, 1 # $t7 = 8 = a * c/512
    sll $s0, $t2, 1 # $s0 = 12 = l ^ b
    add $s2, $t7, $s0 # a * c/512 + l ^ b ////  8 + 12 in $s2 = 20
    ori $s2, $s2, 16
    
    li $v0, 1
    move $a0, $s2
    syscall'''

Upvotes: 0

Views: 146

Answers (0)

Related Questions