【问题标题】:Decimal to Octal using MIPS使用 MIPS 将十进制转换为八进制
【发布时间】:2016-05-19 23:53:17
【问题描述】:

使用 MIPS 汇编将 十进制 转换为 八进制 的最简单方法是什么?

【问题讨论】:

    标签: assembly mips mips32 mars-simulator


    【解决方案1】:

    我是这样写的:

        #the octal number is $t2
        li $t6,0 #remainder
        li $t7,0 #final octal number
        li $t8,1 #placeInNumber
        octalToDecimalLoop:
            rem $t6,$t2,8
            div $t2,$t2,8
            mul $t6,$t6,$t8
            add $t7,$t7,$t6
            mul $t8,$t8,10
            bnez $t2,octalToDecimalLoop
    

    【讨论】:

    • 用 2 的幂除和余数使用 shift / AND 指令效率更高。
    猜你喜欢
    • 2011-08-21
    • 1970-01-01
    • 1970-01-01
    • 2016-05-28
    • 1970-01-01
    • 1970-01-01
    • 2021-01-29
    • 2018-05-23
    • 1970-01-01
    相关资源
    最近更新 更多