0

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'''
darklord
  • 13
  • 4
  • 1
    Are you sure this is right? There's `A` and `a`, very confusing. `A` is an array, whereas `a` is a scalar. `A|B` would seem to be nonsense: maybe `a|b` was intended? You also need to understand the operator precedence, e.g of `|` vs. `*` vs. `-`. (These arrays are using 1-based indexing, so this is not the C language; you'll need to consult your coursework to find the proper operator precedence.) – Erik Eidt Jun 11 '21 at 14:32
  • I was thinking about that too! I mean someone from the institute gave me that question (if you look at the mathematical expressions, there are two **A, a** used and same with the B variable) where I could have used `A[25]` th index value which is 1 and `B[18]` th value which is 7 and `A|B` would be `7|1` which is understandable for me. But anyhow, Thanks! @ErikEidt – darklord Jun 11 '21 at 14:52

0 Answers0