Generating random numbers using a syscall

╄→尐↘猪︶ㄣ 提交于 2019-12-11 15:35:38

问题


I'm trying to generate a random integer from 0-99 (inclusive) but I'm having some difficulty finding where it stores the value to when using the 42 syscall.

So far I have:

li $a1, 100
li $v0, 42
syscall

I'm not sure where the value generated is stored so I can use it though.


回答1:


From a syscall help page: $a0 is the pseudorandom number generator id, $a1is the upper bound, and the returned random number will also be contained in $a0.



来源:https://stackoverflow.com/questions/8394537/generating-random-numbers-using-a-syscall

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