$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. input pattern中常用的正则表达式

    常用的正则表达式 pattern的用法,只是列出来一些常用的正则: 信用卡 [0-9]{13,16} 银联卡 ^62[0-5]\d{13,16}$ Visa: ^4[0-9]{12}(?:[0-9]{ ...

  2. Vue2.0项目打包后只能访问首页,其他页面路径错误找不到

    原因是你使用了vue-router的history,可以尝试去掉  // mode:"history",

  3. Object.defineProperty 与数据绑定的简单实现

    对象是一个属性集合,对象的基本特征是属性名(name)和属性值(value).ES5 增加了属性描述符,包括数据属性描述符(configurable enumerable writable value ...

  4. RollViewPager图片轮播效果开源框架的使用

    RollViewPager是一个自动轮播的Viewpager, 支持无限循环. 触摸时会暂停播放,直到结束触摸一个延迟周期以后继续播放. 看起来就像这样.指示器可以为点可以为数字还可以自定义,位置也可 ...

  5. zookeeper应用 - FIFO 队列 分布式队列

    使用ZooKeeper实现的FIFO队列,这个队列是分布式的. package fifo; import java.util.Collections; import java.util.List; i ...

  6. Centos7安装最新版本的docker

    centos7 安装docker-ce ,最新版本docker,docker阿里云加速docker-ce是指docker的社区版 卸载老版本的 docker 及其相关依赖sudo yum remove ...

  7. Android组件系列----Activity组件详解

    [声明] 欢迎转载,但请保留文章原始出处→_→ 生命壹号:http://www.cnblogs.com/smyhvae/ 文章来源:http://www.cnblogs.com/smyhvae/p/3 ...

  8. WinForm自定义控件

        [ToolboxBitmap(typeof(PropertyGrid))]//设置在工具箱中显示的小图标 public partial class ServiceManage : UserCo ...

  9. 从Azure上构建Windows应用程序映像

    从Azure上构建windows应用程序映像同构建Linux应用程序映像总体流程比较类似,可以参考上图Linux映像的制作发布等流程,具体细节又有所差别. 具体步骤如下: 从Azure管理平台上申请W ...

  10. JBoss jmx-console中的秘密

    JBoss jmx-console中的秘密 https://wenku.baidu.com/view/fe196f047cd184254b35351d.html