ECE 366: Computer Organization- Fall 2018 Project 1: MIPS programming with MARS
ID: 3749207 • Letter: E
Question
ECE 366: Computer Organization- Fall 2018 Project 1: MIPS programming with MARS In this project, you will write a MIPS assembly programs and verify that they run correctly with the simulator MARS. Program I-“6AP mod 17 compute the result of "6 to the power of module 17" 64p mod 17 The value of P is given in data memory location 0x2000 The result (R) should be written back in memory at location 0x2004 1. See below for an example: data P: word 8 R: .word -1Rwill be stored here text a Your code goes here 100% grade Your code should work correctly for PPC [1, noted You are not use multiplication or division instructions, so you'll have to use add and subtract for Ang and C%D operations. However, you can do "shifted add" and "shifted subtract" to accelerate these processes. . To find the matching score of any two 32-bit patterns P1 and P2, count the number of 1's in the result of P1 xor P2, and then subtract the number from 32. Page 1 of 2 180 words English (US)Explanation / Answer
.file 1 ""
.section .mdebug.abi32
.previous
.gnu_attribute 4, 1
.abicalls
.rdata
.align 2
$LC0:
.ascii "Enter a number: "
.align 2
$LC1:
.ascii "%d"
.align 2
$LC2:
.ascii "Factorial of %d is: %d"
.text
.align 2
.globl main
$LFB0 = .
.set nomips16
.ent main
.type main, @function
main:
.frame $fp,48,$31 # vars= 16, regs= 2/0, args= 16, gp= 8
.mask 0xc0000000,-4
.fmask 0x00000000,0
.set noreorder
.cpload $25
.set nomacro
addiu $sp,$sp,-48
$LCFI0:
sw $31,44($sp)
$LCFI1:
sw $fp,40($sp)
movz $31,$31,$0
$LCFI2:
move $fp,$sp
$LCFI3:
.cprestore 16
li $2,1 # 0x1
sw $2,24($fp)
lw $2,%got($LC0)($28)
nop
addiu $4,$2,%lo($LC0)
lw $2,%call16(printf)($28)
nop
move $25,$2
jalr $25
nop
lw $28,16($fp)
addiu $2,$fp,32
lw $3,%got($LC1)($28)
nop
addiu $4,$3,%lo($LC1)
move $5,$2
lw $2,%call16(scanf)($28)
nop
move $25,$2
jalr $25
nop
lw $28,16($fp)
li $2,1 # 0x1
sw $2,28($fp)
b $L2
nop
$L3:
lw $3,24($fp)
lw $2,28($fp)
nop
mult $3,$2
mflo $2
sw $2,24($fp)
lw $2,28($fp)
nop
addiu $2,$2,1
sw $2,28($fp)
$L2:
lw $2,32($fp)
lw $3,28($fp)
nop
slt $2,$2,$3
xori $2,$2,0x1
andi $2,$2,0x00ff
bne $2,$0,$L3
nop
lw $2,32($fp)
lw $3,%got($LC2)($28)
nop
addiu $4,$3,%lo($LC2)
move $5,$2
lw $6,24($fp)
lw $2,%call16(printf)($28)
nop
move $25,$2
jalr $25
nop
lw $28,16($fp)
move $2,$0
move $sp,$fp
lw $31,44($sp)
lw $fp,40($sp)
addiu $sp,$sp,48
j $31
nop
.set macro
.set reorder
.end main
$LFE0:
.size main, .-main
.section .eh_frame,"aw",@progbits
$Lframe1:
.4byte $LECIE1-$LSCIE1
$LSCIE1:
.4byte 0x0
.byte 0x1
.globl __gxx_personality_v0
.ascii "zP"
.uleb128 0x1
.sleb128 -4
.byte 0x1f
.uleb128 0x5
.byte 0x0
.4byte __gxx_personality_v0
.byte 0xc
.uleb128 0x1d
.uleb128 0x0
.align 2
$LECIE1:
$LSFDE1:
.4byte $LEFDE1-$LASFDE1
$LASFDE1:
.4byte $LASFDE1-$Lframe1
.4byte $LFB0
.4byte $LFE0-$LFB0
.uleb128 0x0
.byte 0x4
.4byte $LCFI0-$LFB0
.byte 0xe
.uleb128 0x30
.byte 0x4
.4byte $LCFI2-$LCFI0
.byte 0x11
.uleb128 0x1e
.sleb128 2
.byte 0x11
.uleb128 0x1f
.sleb128 1
.byte 0x4
.4byte $LCFI3-$LCFI2
.byte 0xd
.uleb128 0x1e
.align 2
$LEFDE1:
.ident "GCC: (Debian 4.4.5-8) 4.4.5"
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.