mips

lcov in cross-compile environment

Hello, I have some problems in using gcov/ lcov in a cross-compiler setting. What I have: I took the example main()-Program from the gcov documentation page and successfully compiled, linked and run it. I also was able to run lcov against it to produce the analysis in html pages. All this was in a native i.e. (NON cross-)compiling env...

MIPS fetch address not aligned on word boundary, used .align 4, still no go

any ideas? Why I am getting: Runtime exception at 0x00400020: fetch address not aligned on word boundary 0x00000007 Problem line is: lw $s1,0($a1) #copy arg2 = size of array .data .align 4 #added this, didnt work size: .word 7 .align 4 #added this, didnt work search: .word 30 .align 4 #added this,didnt work ...

C to MIPS translation

Trying to convert this c code into MIPS and run it in SPIM. int A[100], B[100]; for(i=1; i<100; 1++){ A[i] = A[i-1] + B[i]; } So far this is what I have. # comments are delimted by has marks .data A: .word 0:100 # array of 12 integers B: .word 0:100 # array of 12 integers .text main: li $v0, 1 # l...

Some help with MIPS Assembly- jump and link.

Hi all, I've never used MIPS assembly before and it was just introduced in class. I'm working on a homework assignment, but I'm having some difficulty calling a function. Here's what I've worked out so far: .data .align 2 matrix_a: .word 11, 23, 31, 46, 52, 66, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 .text ....

Creating (and accessing) an array in MIPS

I'm trying to create an array in MIPS Assembly, and then add all the elements together. However, when I try to assemble the following, it says Error in read_array line 1 position 7: ".word" directive cannot appear in text segment Assemble: operation completed with errors. Here's my assembly: list: .word 3, 2, 1, 0, 1, 2 li $t0...

count leading zero in single cycle datapath

As you all might know that the MIPS instruction set supports clz (count leading zero) as follows: clz $t0,$t1 count leading zeros t0 = # of leading zeros in t1 I am writing a single cycle datapath in verilog and was just wondering what the ALU needs to support in order for me to do this... any ideas?? ...

Load half word and load byte in a single cycle datapath

There was this problem that has been asked about implementing a load byte into a single cycle datapath without having to change the data memory, and the solution was something below. This is actually quite a realistic question; most memory systems are entirely word-based, and individual bytes are typically only dealt with i...

.word directives in MIPS assembly

.data VALS: .half 0xbead, 0xface RES: .space 4 .text la $t0,VALS lh $t1,($t0) lhu $t2,2($t0) sll $t2,$t2,16 or $t2,$t1,$t2 jal AVG .word -2 .word -6 la $t4,RES sw $v0,($t4) li $v0,10 syscall AVG: lw $v0,($ra) lw $t3,4($ra) add ...

understanding memory address

I am having problems with memory addressing in MIPS. It says that the addressing is word aligned... in the text below I don't understand why it's looking at the 2 least significant bits of the address? why? can someone give me an example to clarify/illustrate the point made here... so is it saying that a valid halfword address are all wh...

MIPS division of signed integers

I'm wondering if anyone might know how to perform a division between two signed integers in MIPS, WITHOUT using the built in division operations. In the problem specs, I'm told the divisor register, ALU, and quotient register are all 32 bits wide, and the remainder register is 64 bits. ...

MIPS: removing non alpha-numeric characters from a string

I'm in the process of writing a program in MIPS that will determine whether or not a user entered string is a palindrome. It has three subroutines which are under construction. Here is the main block of code, subroutines to follow with relevant info: .data Buffer: .asciiz " ...

Issues with MIPS interrupt for tv remote simulator

Hello I am writing a program for class to simulate a tv remote in a MIPS/SPIM enviroment. The functions of the program itself are unimportant as they worked fine before the interrupt so I left them all out. The gaol is basically to get a input from the keyboard by means of interupt, store it in $s7 and process it. The interrupt is cau...

Why do my MIPS crosscompiler works like this for NOT operation?

Hello, I setup my crosscompiler for making MIPS instructions. And it compiles C code well. but I found a weird thing for NOT operations. if i make code like int a; func(!a); and i studied MIPS instructions with text book that says "MIPS converts NOT operation to 'nor with zero'" So i thought it would converted like nor a...

embedded profiler

I am supposed to profile/optimize an application. I am running on a mips machine so valgrind is not an option. Any tool suggestions, tactics? EDIT: I guess I should have given more details. Gprof is not supported in my toolchain. I have tried oprofile; but results seemed incorrect, also I could not get a calltree. I am looking for an a...

reading the file name from user input in MIPS assembly

I'm writing a MIPS assembly code that will ask the user for the file name and it will produce some statistics about the content of the file. However, when I hard code the file name into a variable from the beginning it works just fine, but when I ask the user to input the file name it does not work. after some debugging, I have discove...

How to get LSB bit in MIPS?

Is there a short way to check/get for least significant bit in a 32-bit integer, in MIPS? It is obviously set for the odd numbers and an algorithm which checks for the whole number is odd or even can decide for this. But I just wonder is there a better way to do this... ...

How to shift a binary number by filling MSB with 1?

In MIPS, is there a way to shift a binary number (0000) by filling its MSB with 1 (1000 and next time 1100 and next time 1110 so on...) each time? ...

In MIPS Assembly, how do I truncate to two decimal places if I have a floating point value X.YZDEF in a floating point register?

If I have a value in an "f" register in MIPS, how do I truncate this down to X.YZ from X.YZDEF? Supposedly, you must convert from the float to two ints and display those... How is this done? ...

MIPS (or SPIM): Loading floating point numbers...

Hey hey, I am working on a little mini compiler while trying to learn some MIPS here. Here's my issue: MIPS has an instruction li (load immediate) which would work like this li $5,100 which would load 100 into register 5. However, I need to load floats into registers right now and am struggling with figuring out a way to do it...s...

question about jump in MIPS

What does the PCGPRLEN-1..28 means here?? Where does this 4 bit comes from? ...