2013-02-03 28 views
0

我目前有點卡在我的家庭作業,並懇求一些協助。我們的任務是實施x^4/4!在手臂組裝。我已經成功地計算了x^4和4!的正確值,但是我堅持如何計算顯然具有浮點的分割。我已經實現了一個簡單的除法算法,但有一點幫助,但據我瞭解,這只是用於整數除法,不是嗎?司與浮動結果(作業)

CMP    R2, #0 
BEQ divide_end 


MOV  R0,#0  ;clear R0 to accumulate result 
MOV  R3,#1  ;set bit 0 in R3, which will be 
        ;shifted left then right 
.start 
CMP  R2,R1 
MOVLS R2,R2,LSL#1 
MOVLS R3,R3,LSL#1 
BLS  start 
;shift R2 left until it is about to 
;be bigger than R1 
;shift R3 left in parallel in order 
;to flag how far we have to go 

.next 
CMP  R1,R2  ;carry set if R1>R2 
SUBCS  R1,R1,R2 ;subtract R2 from R1 if this would 
         ;give a positive answer 
ADDCS  R0,R0,R3 ;and add the current bit in R3 to 
         ;the accumulating answer in R0 

MOVS  R3,R3,LSR#1  ;Shift R3 right into carry flag 
MOVCC  R2,R2,LSR#1  ;and if bit 0 of R3 was zero, also 
          ;shift R2 right 
BCC  next   ;If carry not clear, R3 has shifted 
          ;back to where it started, and we 
          ;can end 

.divide_end 

也許我真的很愚蠢這裏,但任何幫助,將不勝感激 非常感謝

+0

你不能只使用浮點指令嗎? –

+0

你的意思是將兩個整數轉換爲浮點數,然後使用VDIV?我不太確定這是否是正確的做法。我可以爲此使用r0-r15,還是必須使用S寄存器? – puelo

+0

結果必須是浮點值並不容易。整數除法是一個合理的選擇,定點除法也是一個合理的選擇。問題陳述是否需要浮點? – 2013-02-03 14:19:20

回答

0

我只是啞巴。我們被允許使用FPU指令。所以我可以使用VDIV!