Sha256: db94cb2f48c8b8812b94830b9877c3618d89e0ac60866ee1acf1a8b5fe9c830e

Contents?: true

Size: 874 Bytes

Versions: 396

Compression:

Stored size: 874 Bytes

Contents

# Convert ascii string of octal digits to integer
#
# $a0 - input, pointer to null-terminated string of chars 0-7
# $v0 - output, integer form of binary string
# $t0 - ascii value of the char pointed to
# $t1 - integer value (0-7) of the char pointed to

.globl octal_convert

octal_convert:
        li      $v0, 0                  # Reset accumulator to 0.

loop:
        lb      $t0, 0($a0)             # Load a character,
        beq     $t0, $zero, end         # if it is null then return.
        sll     $v0, $v0, 3             # Otherwise multiply accumulator by 8,
        addi    $t1, $t0, -48           # calculate the value of the character,
        or      $v0, $v0, $t1           # and add that to the accumulator.
        addi    $a0, $a0, 1             # Finally, increment the pointer
        j       loop                    # and loop.

end:
        jr $ra

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.139 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.138 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.137 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.136 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.135 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.134 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.133 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.132 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.131 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.130 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.129 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.128 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.127 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.126 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.125 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.124 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.123 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.122 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.121 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.120 tracks/mips/exercises/octal/example.mips