我目前有点卡在我的家庭作业中,并请求一些帮助。我们的任务是实现 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
也许我在这里真的很愚蠢,但任何帮助将不胜感激非常感谢