對於我正在處理的程序,我需要編寫一個子程序,根據用戶的輸入(主要)對該數組進行分區。所以基本上,如果原始數組是[4.2,-1.2,16.5,12.3,3.7,3.8,3.9],並且用戶輸入6.1作爲分區值,那麼這兩個數組將是[4.2,-1.2,3.7,3.8,3.9]和[16.5,12.3]。我感到困惑的是我知道我需要使用兩個循環,我知道我必須使用c.lt.d
,bc1f
和類似的東西來比較這些值,但我不完全清楚如何正確執行。任何人都可以幫我解決這個問題嗎?我將如何去分割MIPS程序集中的數組?
此外,這是在子程序的基本JIST:
###########################################################
# Subprogram Description
#
# 'partition_array'
#
# 1. Determine how many values in source are < partition value
# 2. Allocate two arrays on heap (one w/ values < partition value,
# one >= partition value)
# 3. Copy the values from the source array into appropriate destination array
# 4. Return base address and length of both
#
###########################################################
# Arguments In and Out of subprogram
#
# $sp source array base address (IN)
# $sp+4 source array length (IN)
# $sp+8 partition value, double-precision (IN)
# $sp+16 "less" array base address (OUT)
# $sp+20 "less" array length (OUT)
# $sp+24 "greater" array base address (OUT)
# $sp+28 "greater" array length (OUT)
###########################################################
.data
###########################################################
.text
partition_array:
partition_array_end:
jr $ra #return to calling location
###########################################################
無效的調用約定。 MIPS ABI全部使用幾個寄存器作爲前幾個參數。這些決定將共同打破手寫彙編的觀點。 – Kaz
@Kaz你是在回答我的問題還是隻是抱怨MIPS? –