I'm having trouble with my program. My goal is to iterate through the array and add only the even values together. When I run this program it hangs and I don't know why.
.text
.globl main
main:
lui $16,0x1000
lw $17,0($16)
addiu $16, $16, 0
addiu $18, $0, 2
addiu $19, $0, 28
loop:
beq $16, $19, exit
div $17, $18
mfhi $13
beq $13, $0, even
addiu $16, $16, 4
j loop
even:
add $10, $10, $17
addiu $16, $16, 4
j loop
exit:
.data
size: .word 8
array: .word 23, -12, 45, -32, 52, -72, 8, 13
C Code to Sum up Even values in an array:
MIPS for the above code::
.file 1 "" .section .mdebug.abi32 .previous .nan legacy .module fp=32 .module nooddspreg .abicalls .section .rodata.str1.4,"aMS",@progbits,1 .align 2 $LC0: .ascii "%d \000" .section .text.startup,"ax",@progbits .align 2 .globl main .set nomips16 .set nomicromips .ent main .type main, @function main: .frame $sp,72,$31 # vars= 40, regs= 2/0, args= 16, gp= 8 .mask 0x80010000,-4 .fmask 0x00000000,0 .set noreorder .cpload $25 .set nomacro addiu $sp,$sp,-72 lw $25,%call16(memset)($28) sw $16,64($sp) addiu $16,$sp,24 .cprestore 16 movz $31,$31,$0 li $6,40 # 0x28 move $4,$16 sw $31,68($sp) .reloc 1f,R_MIPS_JALR,memset 1: jalr $25 move $5,$0 li $2,23 # 0x17 sw $2,24($sp) li $2,-12 # 0xfffffffffffffff4 sw $2,28($sp) li $2,45 # 0x2d sw $2,32($sp) li $2,-32 # 0xffffffffffffffe0 sw $2,36($sp) li $2,52 # 0x34 sw $2,40($sp) li $2,-72 # 0xffffffffffffffb8 sw $2,44($sp) li $2,8 # 0x8 sw $2,48($sp) lw $28,16($sp) li $2,13 # 0xd sw $2,52($sp) move $6,$0 move $2,$0 li $4,32 # 0x20 addu $3,$16,$2 $L7: lw $3,0($3) nop andi $5,$3,0x1 bne $5,$0,$L2 nop addu $6,$6,$3 $L2: addiu $2,$2,4 bne $2,$4,$L7 addu $3,$16,$2 lw $5,%got($LC0)($28) lw $25,%call16(__printf_chk)($28) addiu $5,$5,%lo($LC0) .reloc 1f,R_MIPS_JALR,__printf_chk 1: jalr $25 li $4,1 # 0x1 lw $31,68($sp) lw $16,64($sp) move $2,$0 j $31 addiu $sp,$sp,72 .set macro .set reorder .end main .size main, .-main
I'm having trouble with my program. My goal is to iterate through the array and add...
im trying to complete mips program code about a calculator program that can calculate integer addition / subtraction written using the MIPS assembler. im having hard times to debug this. The input is given to the array of Formula char (base address $ s0) in the form of a formula. The null character (\ 0, ASCII code 0) is placed at the end. The calculation result is given to the register $ s1 and the overflow is ignored. For example,...
Write a MIPS program that prints(displays) "Hello World" using MMIO (NOT syscall!) Here is a screenshot of a MIPS program that prints user input to the screen. And I need something that displays "Hello World" without taking any input. Please help! Thanks. The output should be something like this but without the input .data 7 strl:.asciiz "\nStart entering characters in the MMIO Simulator" .text 10 .globl echo 12 13 14 15 16 17 echo: al Read # single print statement...
The MIPS assembly program given here is expected to find the sum of elements in array "myArr. Even though the code is syntactically correct, there are four bugs because of which the program is not glving the required output. With the help of the line numbers given identify the bug. Write the line number where you find the bug and give how the correct statement to eliminate the corresponding logical error (10 points partial points given for partial correct answers)...
I have this MIPS program and I'm having trouble with it. This program is user inputs numbers until zero and sorts and print the numbers in order. Please soove this issue. You can use any sorting algorithm except bubble sort. Need it as soon as possible. Here is the code:.datanum: .word 0space: .byte ' ' .text main: # la $t0, val # loads val into a register # li $t1, 0 #keeps track of how many numbers entered la $a0,...
I want to calculate Y[2]=X[3]+X[4] I'm not sure that I wrote right codes. .text main . la $50, x #get base address of x la $s1, y #get base address of y lw $to, 12 ($50)#get data from memory of x[3] lw $t1 , 1 6($50) #get data from memory of x[4] add $t2, $t0, $t1 sw $t2, 8($51 ) #store result to y[2] li $v0, 10 #exit program syscall data x: word 5, 1, 17,-4, 6, 3 y: .word...
I am having problems with reading a file into an array. This is my code. This is what I get when I run my program. But this is my text file I am reading. I tried everything and it seems to be reading in the last digit of the file. I want to read in their names line by line into an array and ultimatly also read in the scores line by line. 1 E/7 Programming Assignment 6.cpp Defines the...
Please comment the MIPS code to help me understand. Here is what the code accomplishes. Here is the code, partially commented. .data Matrix: .word 41,45,5, 34,8, 15,16,23,44,48,12,32,18,47,22,8,22 .word 46,40,42,33,13,38,27,6, 29,25,18,40,47,22,26,14,3 .word 7, 48,35,9, 43,38,9, 49,28,25,42,5, 44,10,5, 38,14 .word 46,33,16,6, 13,20,31,1, 8, 17,1, 47,28,46,14,28,7 .word 32,2, 48,25,41,29,14,39,43,46,3, 39,32,49,41,28,46 .word 5, 43,2, 48,13,4, 33,41,32,19,9, 25,30,22,2, 9, 40 .word 14,47,22,18,47,3, 35,44,18,6, 33,22,11,6, 47,50,4 .word 28,34,20,30,18,27,38,5, 26,40,37,23,16,13,37,8,7 .word 48,38,39,12,10,39,23,20,21,20,33,16,24,21,25,3,46 .word 49,38,40,38,13,47,5, 13,4, 13,23,26,12,30,29,29, 3 .word 8, 20,10,13,31,7, 12,41,12,21,28,26,43,14,35,10,19 .word 49,33,25,26,24,29,46,22,7, 5, 15,41,10,31,19,41,27 .word 48,9,...
5. Consider the SPIM code below. globl main .text main: ori $t1, $0, 10 ori $t2, $0, 11 add $t3, $t1,$t2 move $t4, $t3 The following image shows a screen shot of QtSPIM page when this program is loaded, and executed in step-by step fashion. Current instruction is highlighted. Data Text x Text Regs Int Regs [16] Int Regs [16] PC = 400028 EPC 0 Cause = 0 BadAddr = 0 Status = 3000ff10 HI LO = 0 = 0...
Transfer C code of selection sort to MIPS code and print the sorted array/results data Array: word 43, -5, 11, 12, 64, -7, 14, 71, 70, 13, -27 string: asciz"In" # Trantec the C code of selection sort to MIPS code. Do not modify the existing code and structure! text main la ŞtO, Array li $t1, 0 li $t7,11 mul $17, $17, 4 subi $t8,$t7, 4 # array length n-11 # 4*n #4*(n-1) # lis in $t1 and j is...
i'm having trouble making an else statement that will allow the program to add and output the average the valid numbers inputed into the program. Here's my output: Enter Score 1:36 Enter Score 2:-1 Invalid Input Enter Score 2:89.5 Enter Score 3:42 Enter Score 4:66.3 Enter Score 5:93 You entered: 36.000000, 89.500000, 42.000000, 66.300000, 93.000000 Total Score: 362.800000 Average Score: 72.560000 Max Score: 93.000000 Min Score: 36.000000 Here's my code: #include <stdio.h> int main(void) { double score[5]; double min; double...