






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A comprehensive set of exercises and solutions for mips assembly language, covering various aspects of computer architecture. It includes examples of arithmetic operations, data manipulation, memory access, control flow, and function calls. The solutions are detailed and well-explained, making it an excellent resource for students learning mips assembly language.
Typology: Assignments
1 / 10
This page cannot be seen from the preview
Don't miss anything!







Solutions
Chapter 2 Solutions S-
add f, f, g
add $t0, $s6, $t lw $t1, 16($t0) sw $t1, 32($s7)
add $t1, $s7, $s lw $s0, 0($t0) lw $t0, 4($t0) add $t0, $t0, $s sw $t0, 0($t1)
temp2 = Array[1]; Array[0] = Array[4]; Array[1] = temp; Array[4] = Array[3]; Array[3] = temp2;
lw $t1, 4($s6) lw $t2, 16($s6) sw $t2, 0($s6) sw $t0, 4($s6) lw $t0, 12($s6) sw $t0, 16($s6) sw $t1, 12($s6)
Chapter 2 Solutions S-
sll $t0, $t0, 26 ori $t2, $0, 0x03ff sll $t2, $t2, 16 ori $t2, $t2, 0xffff and $t1, $t1, $t or $t1, $t1, $t
sll $t1, $t3, 4
S-6 Chapter 2 Solutions
beq $t2, $0, loop
do { B += 2;
} while ( i > 0)
beq $0, $0, TEST LOOP1: addi $t1, $0, 0 beq $0, $0, TEST LOOP2: add $t3, $t0, $t sll $t2, $t1, 4 add $t2, $t2, $s sw $t3, ($t2) addi $t1, $t1, 1 TEST2: slt $t2, $t1, $s bne $t2, $0, LOOP addi $t0, $t0, 1 TEST1: slt $t2, $t0, $s bne $t2, $0, LOOP
result += MemArray[s0]; s0 = s0 + 4; }
S-8 Chapter 2 Solutions
sw $ra,8($sp) sw $s1,4($sp) sw $s0,0($sp) move $s1,$a move $s0,$a jal func move $a0,$v add $a1,$s0,$s jal func lw $ra,8($sp) lw $s1,4($sp) lw $s0,0($sp) addi $sp,$sp, jr $ra
sw $ra, ($sp) add $t6, $0, 0x30 # ‘0’ add $t7, $0, 0x39 # ‘9’ add $s0, $0, $ add $t0, $a0, $ LOOP: lb $t1, ($t0) slt $t2, $t1, $t bne $t2, $0, DONE slt $t2, $t7, $t bne $t2, $0, DONE sub $t1, $t1, $t beq $s0, $0, FIRST mul $s0, $s0, 10 FIRST: add $s0, $s0, $t addi $t0, $t0, 1 j LOOP
Chapter 2 Solutions S-
DONE: add $v0, $s0, $ lw $ra, ($sp) addi $sp, $sp, 4 jr $ra
lui $t1, top_16_bits ori $t1, $t1, bottom_16_bits
ll $t0,0($a0) bnez $t0,trylk sc $t1,0($a0) beqz $t1,trylk lw $t2,0($a1) slt $t3,$t2,$a bnez $t3,skip sw $a2,0($a1) skip: sw $0,0($a0)
slt $t1,$t0,$a bnez $t1,skip mov $t0,$a sc $t0,0($a1) beqz $t0,try skip: