0% found this document useful (0 votes)
24 views4 pages

Cse332 Assi 2-1

The document contains an assignment by Md. Sabbir Hossain Tamim for a CSE course, detailing various assembly language instructions and their corresponding opcodes and bit patterns. It includes code for loading values, storing, and summing an array of integers, as well as control flow instructions. The assignment demonstrates understanding of MIPS assembly language programming concepts.

Uploaded by

sabbir.tamim3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views4 pages

Cse332 Assi 2-1

The document contains an assignment by Md. Sabbir Hossain Tamim for a CSE course, detailing various assembly language instructions and their corresponding opcodes and bit patterns. It includes code for loading values, storing, and summing an array of integers, as well as control flow instructions. The assignment demonstrates understanding of MIPS assembly language programming concepts.

Uploaded by

sabbir.tamim3
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

ASSIGNMENT-02

Name: Md. Sabbir Hossain Tamim


ID: 2222037642
Course: Cse332
Sec:05

Sabbir Hossain Tamim


1. Ans

1. add r23, r11, r0 # r23 = r11 + 0 (move r11 to r23)

2. li r15, 265140

3. li r1, 55259 # Load value directly

li r2, 40000 # Load address directly

sw r1, 0(r2) # Store value

4. lw r1, 0b1001000(r0)

lw r2, 0b100010011100(r0)
add r3, r1, r2

sw r3, 0b10000000(r0)

5. lw r3, 524328(r0)

add r4, r3, r2

sw r4, 524312(r0)

6. lw r1, 400(r0)

ble r1, r10, lab1

2. Ans

1. lw r16, 0(r13)

• Opcode for lw is 100011 (35 in decimal).

• Bit Pattern: 100011 01101 10000 0000 0000 0000 0000

2. addi r8, r2, -513


• Opcode for addi is 001000 (8 in decimal).
• Bit Pattern: 001000 00010 01000 1111 1110 0000 0000
3. nop (no operation)

• Typically represented as: 000000 00000 00000 00000 00000 000000 (all zeros).

• Bit Pattern: 0x00000000

4. sw r8, -18(r4)

• Opcode for sw is 101011 (43 in decimal).

• Bit Pattern: 101011 00100 01000 1111 1111 1110 1110

5. bne r3, r0, lap (Assuming lap = 25 instructions away):

• Opcode for bne is 000101 (5 in decimal).

• Bit Pattern: 000101 00011 00000 0000 0000 0001 1001

3. Ans

.data

ARRAY: .word 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21

N: .word 11

.text
.globl main

main:

la $a0, ARRAY # Load address of ARRAY into $a0

jal sum_array # Call sum_array function

move $a0, $v0 # Move result to $a0 for printing

la $a1, msg # Load address of message


li $v0, 4 # Print string syscall
syscall

li $v0, 10 # Exit syscall

syscall

sum_array:
la $t0, ARRAY # Load address of ARRAY into $t0

li $t1, 0 # $t1 = i (index)

li $t2, 0 # $t2 = total

sum_loop:

lw $t3, 0($t0) # Load ARRAY[i] into $t3

add $t2, $t2, $t3 # total += ARRAY[i]

addi $t0, $t0, 4 # Move to next element

addi $t1, $t1, 1 # i++


li $t4, 11 # Load N

bne $t1, $t4, sum_loop # Repeat if i < N

move $v0, $t2 # Return total in $v0

jr $ra # Return to caller

You might also like