



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
Main points of this exam paper are: Assembly Language, Section Meeting, Meeting Time, Discussion Section, Assembly Language, Legal Assembly, Checkmark, Machine, First Instruction, Tal Program
Typology: Exams
1 / 5
This page cannot be seen from the preview
Don't miss anything!




Question Max Points Your Points 0 1 1 17 2 5 3 6 4 6 5 5 6 5 7 15 8 20 Total 80
.data word5: .word 5 abc5: .byte ’a’, ’b’,’c’, zero: .word 0 .text __start: # (1a) (1b) (1c)
if
[$4]= main: lui $4, 0 1 -----------------|----------------|------
addi $4,$0,0 7 -----------------|----------------|------
__start: li $a0,4 #f(4) jal f done
f: sub $sp,$sp,8 # adjust the stack for 2 items sw $ra,4($sp) # save the return address sw $a0,0($sp) # save the argument n addi $v0,$zero,1 # initialize answer
loop: slt $t0,$a0,2 # test for n < 2 beq $t0,$zero,L1 # if n>1, go to L addi $sp,$sp,8 # pop off 2 items off stack
jr $ra #return to after jal
L1: mul $v0,$a0,$v sub $a0,$a0,1 # n >=1; argument gets (n-1) j loop