hardware - Mips branch: testing equality -
i need know how can test equality of 2 registers in mips without using branches? need make new instruction same beq without using branches... labeling part can done using jump instruction, how can check equality ? in advance
if you've got 2 numbers x
, y
, , x - y
equals 0, x
, y
equal.
so, example, if 2 values want compare in $t0
, $t1
:
# $t2 0 if $t0 , $t1 equal, , non-zero otherwise subu $t2, $t0, $t1
if want normalize result either 0 (non-equal) or 1 (equal), expand above with:
# set $t2 1 if it's non-zero sltu $t2, $zero, $t2 # flip lsb 0 becomes 1, , 1 becomes 0 xori $t2, $t2, 1
Comments
Post a Comment