簡體   English   中英

mips匯編指令beq和bne的16位十六進制范圍

[英]16 bits hex range for mips assembly instruction beq and bne

我已經為mips匯編語言實現了beq指令。 根據我對beq指令( beq $s, $t, i )的理解,我可以采用整數值或十六進制值。 我已經為16位整數值建立了界限。 我想知道16位十六進制值的界限是什么,所以當我太大(或太小?)時,它將在執行之前輸出錯誤。 以下是二進制的beq指令。

Branch On Equal
beq $s, $t, i
0001 00ss ssst tttt iiii iiii iiii iiii

我嘗試了(i> 0xffff),但似乎無法涵蓋所有​​情況。 我在這里該怎么辦? 謝謝。

hex(0 <= i <= 65535);應在02^16 - 1 hex(0 <= i <= 65535);
對於int(-32768<=i<=32767)它應該在-2^152^15 - 1 int(-32768<=i<=32767)

當您需要有條件地分支超過+-2 ^ 15條指令(字節偏移=二進制補碼16位<< 2)時,可以有條件地跳過可以到達目標的無條件跳轉。

beq $s, $t,  target      # short jump, approx +- 2^17 bytes

j使用偽直接尋址 ,保持PC的前4位,用26位的<< 2立即更換休息。 這使您可以在與代碼相同的對齊地址空間的1/16中到達任何目標地址。

bne $s, $t,  .nojump
j   target               # anywhere with the same top 4 bits
.nojump:

與將地址放入寄存器並使用jr到達任何32位地址相比:

bne $s, $t,  .nojump
lui  $t0,      %hi(target)
ori  $t0, $t0, %lo(target)      # this is what  la $t0, target does.  It might use addui, but whatever
jr   $t0
.nojump:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM