Compare the last binary digit to 1 in MIPS assembly

五迷三道 提交于 2019-12-25 00:17:59

问题


I have to check if a number is even or odd.

My strategy:

  1. a number is even if ends with 0
  2. a number is odd if ends with 1

How do I compare the last digit of a register value to a 0 or to a 1 ?

I tried:

andi $t7, $t0, 0 # where $t0 = 3 in decimal so should be 0b11

it doesnt work :( Any hint?

来源:https://stackoverflow.com/questions/13772552/compare-the-last-binary-digit-to-1-in-mips-assembly

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!