![](/img/trans.png)
[英]MIPS Assembly code to find all the prime numbers below an inputted number
[英]Calculating Prime Numbers in MIPS Assembly
我目前正在開發一個程序,該程序使用PCSPIM在MIPS匯編中使用遞歸計算最多200個素數。 到目前為止,我已經填充了一個1-200的數字數組和一個成功地包含所有1的二進制向量列表。 我苦苦掙扎的概念是如何使用堆棧框架來幫助完成該過程。
這是我擁有的堆疊框架:
subu $sp,$sp,32 # Set up the stack frame
sw $ra, 28($sp) # save $ra register to the stack
sw $fp, 24($sp) # save $fp register to the stack
addu $fp, $sp, 28 # set $fp register to the end of the stack
我只是不明白這將如何幫助我找到素數。 任何見解將不勝感激!
如果您熟悉Eratosthenes的篩網,則無需遞歸即可找到素數。 與使用遞歸相比,此方法要簡單得多,並且內存效率更高,並且您無需使用堆棧。
我無法通過“這將如何幫助我找到質數”來幫您,因為您從未指定要使用的算法。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.