如何计算转移目标地址和分支目标地址? [英] How to Calculate Jump Target Address and Branch Target Address?

查看:2962
本文介绍了如何计算转移目标地址和分支目标地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的汇编语言即可。我正在读关于 MIPS 架构和我坚持的跳转目标地址分支目标地址如何计算每个他们。

I am new to Assembly language. I was reading about MIPS architecture and I am stuck with Jump Target Address and Branch Target Address and how to calculate each of them.

我会非常感激,如果有人能帮助我。
先谢谢了。

I would be very thankful if anyone can help me out. Thanks in advance.

推荐答案

在MIPS分支指令只有16位偏移来确定下一条指令。我们需要添加到这个16位的值来确定下一个指令寄存器,这个寄存器实际上是由建筑暗示。它是PC寄存器自个人电脑被取指周期期间更新(PC + 4),使得其持有的下一个指令的地址。我们还限制在分支距离-2 ^ 15 + 2 ^ 15 - 1 从分支指令(指令后)指令。然而,这并不是真正的问题,因为大多数分支是当地的反正。

1. Branch Address Calculation

In MIPS branch instruction has only 16 bits offset to determine next instruction. We need a register added to this 16 bit value to determine next instruction and this register is actually implied by architecture. It is PC register since PC gets updated (PC+4) during the fetch cycle so that it holds the address of the next instruction. We also limit the branch distance to -2^15 to +2^15 - 1 instruction from the (instruction after the )branch instruction. However, this is not real issue since most branches are local anyway.

所以一步一步:


  • 登入延长16位偏移值,以preserve它的价值。

  • 乘用造成4价值这背后的原因是,如果我们要分支的一些地址,PC已经是字对齐,然后立即值必须字对齐为好。但是,它没有任何意义,使眼前的字对齐的,因为我们将迫使他们成为00浪费低两位。

  • 现在,我们有32位地址。这个数值添加到PC + 4,这是你的分支地址。

有关跳转指令的Mips只有26位来确定跳转位置。此外,跳跃是相对于以MIPS计算机。像分支,直接跳到值必须字对齐,因此,我们需要四到乘26位地址。

For Jump instruction Mips has only 26 bits to determine Jump location. Besides, jumps are relative to PC in MIPS. Like branch, immediate jump value need to be word-aligned;therefore, we need to multiply 26 bit address with four.

一步一步再次:


  • 乘以26位值与4。

  • 因为我们都在跳相对于PC值,第一串联PC值的4位来离开我们的跳转地址的。

  • 结果地址跳转值。

在换言之,与的低26位取代PC的低28位
取出的指令左移2位离开了。

In other words, replace the lower 28 bits of the PC with the lower 26 bits of the fetched instruction shifted left by 2 bits.

来源:毕尔肯大学CS 224课程的PPT

Source: Bilkent University CS 224 Course Slides

这篇关于如何计算转移目标地址和分支目标地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆