mips

Call stack backtrace in C

蓝咒 提交于 2019-12-29 08:24:31
问题 I am trying to get call stack backtrace at my assert/exception handler. Can't include "execinfo.h" therefore can't use int backtrace(void **buffer, int size); . Also, tried to use __builtin_return_address() but acording to :http://codingrelic.geekhold.com/2009/05/pre-mortem-backtracing.html ... on some architectures, including my beloved MIPS, only __builtin_return_address(0) works.MIPS has no frame pointer, making it difficult to walk back up the stack. Frame 0 can use the return address

Saving integers as Strings in MIPS

你。 提交于 2019-12-29 02:00:07
问题 I was just wondering, is there any way in MIPS to store a summation of numbers as a string and later read them byte by byte, for example: the sum 657 -> sw into a .ascii directive -> later lb on the first index to get 6 (in ascii code) same with 5 and so on. Is this possible? 回答1: Of course. The ".ascii" directive is none but a .byte directive focused on the storage of ASCII text .ascii "PP" is like .byte 80,80 You can use .space to make room for your ASCII string, and then use the buffer in

Why would we use addiu instead of addi?

你离开我真会死。 提交于 2019-12-28 13:56:09
问题 In MIPS assembly, what is the benefit of using addiu over addi ? Isn't addiu unsigned (and will ruin our calculations?) 回答1: and will ruin our calculations No, MIPS uses two's complement, hence the same instruction for addition/subtraction can be used for both signed and unsigned operations. There's no difference in the result. That's also true for bitwise instructions, non-widening multiplication and many other operations. See Which arithmetic operations are the same on unsigned and two's

How does a zero register improve performance?

谁都会走 提交于 2019-12-28 04:28:06
问题 In the MIPS ISA, there's a zero register ( $r0 ) which always gives a value of zero. This allows the processor to: Any instruction which produces result that is to be discarded can direct its target to this register To be a source of 0 It is said in this source that this improved the speed of the CPU. How does it improve performance? And what are the reasons why not all ISA adopt this zero register? $r0 is not general purpose. It is hardwired to 0. No matter what you do to this register, it

the answer is always wrong in this MIPS recursion . got 10, supposed to be 55

℡╲_俬逩灬. 提交于 2019-12-25 18:55:34
问题 This code is supposed to print the sum of numbers from 10 to 0. It should be printing 55, but is printing 10 instead. Can you help me figure out where it's going wrong? main: # initialize values to 3 registers addi $a0,$zero,10 jal sum # call method # Print out the summation upto 10 li $v0,1 # print integer add $a1,$v0,$zero # load return value into argument syscall li $v0,10 # Exit syscall sum: addi $sp,$sp,-8 # allocate space on stack sw $ra,0($sp) # store the return address sw $a0,4($sp) #

Is there any simple way or macro to load 64bit address into mips64 GPR

半腔热情 提交于 2019-12-25 15:57:31
问题 I want to load 64 bit address into MIPS64 General Purpose Register(GPR). I can do it by lui $at, LabelAddr[63:48] ori $at, $at, LabelAddr[47:32] sll $at, 16 ori $at, $at, LabelAddr[31:16] sll $at, 16 ori $at, $at, LabelAddr[15:0] But, Is there any other way to do it? I got some information from this But i want to know what is "constant pool" and how to create it and how to access it? 回答1: The "simple" way is to let the assembler handle it using the dla pseudoinstruction. It will expand to

Is there any simple way or macro to load 64bit address into mips64 GPR

旧巷老猫 提交于 2019-12-25 15:56:18
问题 I want to load 64 bit address into MIPS64 General Purpose Register(GPR). I can do it by lui $at, LabelAddr[63:48] ori $at, $at, LabelAddr[47:32] sll $at, 16 ori $at, $at, LabelAddr[31:16] sll $at, 16 ori $at, $at, LabelAddr[15:0] But, Is there any other way to do it? I got some information from this But i want to know what is "constant pool" and how to create it and how to access it? 回答1: The "simple" way is to let the assembler handle it using the dla pseudoinstruction. It will expand to

VHDL Error (10818): Can't infer register

荒凉一梦 提交于 2019-12-25 14:00:43
问题 So I am a beginner in VHDL and I am trying to code a MIPS processor for a FPGA. The file for the CPU Register is not compiling. It is generating an error code as following Error (10818): Can't infer register for "Reg[0][2]" at cpu_register.vhd(32) because it does not hold its value outside the clock edge library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity cpu_register is Port ( Source_Register_Address : in std_logic_vector(4 downto

How to set a floating point register to 0 in MIPS (or clear its value).

时光毁灭记忆、已成空白 提交于 2019-12-25 06:38:57
问题 I'm currently implementing a square matrix multiplier containing single floating point numbers in MIPS assembly line code. My problem is that once I am done summing the multiplications of the corresponding rows and columns in order to calculate my dot product I want to clear that floating point register so I can calculate the dot product for the next entry in the product matrix.Right now I keep adding the current dot product with all the previous dot products. Things I've tried to set the

Call a subroutine on each character in string - MIPS

霸气de小男生 提交于 2019-12-25 06:07:58
问题 I'm new to MIPS assembly, I want to write a routine that takes the memory address of a string and the memory address of another callback subroutine. This routine will go through every letter in the string and for each letter call the subroutine (this prints the ASCII value of each letter). The pseudo code would look something like this: string_for_each(string, subroutine) { for_each_character_in_string { subroutine(address_of(character)) } } This is what my routine looks like right now: