$ra寄存器中存入的是pc的值(程序运行处的地址),调用函数时,在跳转前,必须保存当前地址(pc的值),以便后来返回。jal $ra 保存后跳转,jr $ra,返回到跳转前,通过$ra保存进入上层栈地址。

jal
    直接跳转指令,并带有链接功能,指令的跳转地址在指令中,跳转发生时要把返回地址存放到R31寄存器(ra)中。
jr
    使用寄存器的跳转指令,跳转地址在寄存器中。

所以根据ra定位core位置时,可以直接在ra位置前找jal便可以找到当前正在执行的函数。

转自http://user.it.uu.se/~justin/Teaching/NewDarkSlides/lecture5.pdf

•  As in high level languages , when programming in assembly language you should split up your program into smaller functions, that you can reuse.

•  One of the key ideas with functions is that you can call them
from any where and return back to where you called the function from.

•  The MIPS processor has two instructions that enable you to call functions, jr and jal.
•  Jump and link.
                    jal  label
   Copies the address of the next instruction into the register $ra
(register 31) and then jumps to the address label.

•  jr  $register jumps to the address in $register most common use
                    jr  $ra

            .data
str: .asciiz "Hello mum!.\n"
.text
.globl main #necessary for the assembler
main: jal message
jal message
li $v0,
syscall #exit the program gracefully
message: la $a0,str
li $v0,
syscall #Magic to printhings on the screen.
jr $ra

•  There are many way of passing values to functions, but there is a convention that most programs on the MIPS follow.
•  $a0-$a3 (registers 4 to 7) arguments 1-4 of a function.

•  $v0-$v1 (registers 2 and 3) results of a function.

        li  $a0,
li $a1,
li $a3,
jal silly #Now the result of the function is is $v0.
li $v0,
syscall
silly: add $t0,$a0,$a1
sub $v0,$a3,$t0
jr $ra

ra寄存器定位core的更多相关文章

  1. iOS 苹果自带地图定位Core Location

    Core Location是iOS SDK中一个提供设备位置的框架.可以使用三种技术来获取位置:GPS.蜂窝或WiFi.在这些技术中,GPS最为精准,如果有GPS硬件,Core Location将优先 ...

  2. 【Z】段错误Segment Fault定位,即core dump文件与gdb定位

    使用C++开发系统有时会出现段错误,即Segment Fault.此类错误程序直接崩溃,通常没有任何有用信息输出,很难定位bug,因而无从解决问题.今天我们介绍core dump文件,并使用gdb进行 ...

  3. Core文件作用、设置及用法

    http://blog.csdn.net/lanmolei814/article/details/45201693 ====================================== 1.C ...

  4. Linux上调试core文件(Good)

    coredump文件 什么是coredump? 通常情况下coredmp包含了程序运行时的内存,寄存器状态,堆栈指针,内存管理信息等.可以理解为把程序工作的当前状态存储成一个文件.许多程序和操作系统出 ...

  5. GDB Core,gdb 调试大全,core文件调试

    编译: gcc -g -o hello hello.c gdb 调试: 基本 gdb 命令. 命 令 描 述 小结:常用的gdb命令 backtrace 显示程序中的当前位置和表示如何到达当前位置的栈 ...

  6. 学会用core dump调试程序错误

    最来在项目中遇到大型程序出现SIGSEGV ,一直不知道用core dump工具来调试程序,花了近一周的时间,才定位问题,老大很生气,后果很严重,呵呵,事后仔细学习了这块的知识,了解一点core du ...

  7. gdb core调试

    原文链接 http://blog.163.com/lanka83/blog/static/32637615200801793020182/http://blog.csdn.net/taina2008/ ...

  8. 【转】段错误调试神器 - Core Dump详解

    from:http://www.embeddedlinux.org.cn/html/jishuzixun/201307/08-2594.html 段错误调试神器 - Core Dump详解 来源:互联 ...

  9. Unix 用gdb分析core dump文件

    产生core文件条件 用ulimit -c 指定core文件大小来开启core文件的生成,如:ulimit -c unlimited 用gdb分析core文件的条件 可执行程序在编译时,需加入-g参数 ...

随机推荐

  1. HTML利用posotion属性定位 小技巧

    1.居中效果 父级DIV (index-top )属性设置为 text-align:center; 子级DIV( tabIndex-main)属性设置为 margin:0 auto;   2.左右对齐 ...

  2. L3(SP+OO+UT)能力评估

  3. Reset GitLab Root Password

    重置gitlab管理员密码 Log into your server with root privileges. Then start a Ruby on Rails console. Start t ...

  4. Vue 框架-10-搭建脚手架 CLI

    Vue 框架-10-搭建脚手架 CLI + 批处理快捷启动 脚手架是通过 webpack 搭建的开发环境 使用 ES6 语法 打包和压缩 JS 为一个文件 项目文件在环境中,而不是浏览器 实现页面自动 ...

  5. 612.1.002 ALGS4 | Analysis of Algorithms

    我们生活在大数的时代 培养数量级的敏感! Tip:见招拆招 作为工程师,你先要能实现出来. 充实基础,没有什么不好意思 哪怕不完美.但是有时候完成比完美更重要. 之后再去想优化 P.S.作者Rober ...

  6. python及pandas,numpy等知识点技巧点学习笔记

    python和java,.net,php web平台交互最好使用web通信方式,不要使用Jypython,IronPython,这样的好处是能够保持程序模块化,解耦性好 python允许使用'''.. ...

  7. twemproxy源码分析

    twemproxy是twitter开源的redis/memcached 代理,数据分片提供取模,一致性哈希等手段,维护和后端server的长连接,自动踢除server,恢复server,提供专门的状态 ...

  8. 分别用C/C++ 和 C#实现简单的观察者模式

    网上找了很多关于观察者模式的代码例子和文章,都写的比较复杂,我个人还是喜欢从易到难,今天自己参考网上资料,也写了一个简单观察者模式的例子,简单的复习了一下Observer 模式,Observer 模式 ...

  9. 使用 sar 和 kSar 来发现 Linux 性能瓶颈

    作者: Vivek Gite 译者: LCTT qhwdw | sar 命令用用收集.报告.或者保存 UNIX / Linux 系统的活动信息.它保存选择的计数器到操作系统的 /var/log/sa/ ...

  10. 水晶报表自定义纸张大小打印 (Crystal Report Print with custom paper size)

    System.Drawing.Printing.PrintDocument doc = new PrintDocument(); doc.PrinterSettings.PrinterName = & ...