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.180 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.179 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.178 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.177 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.176 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.175 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.174 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.173 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.172 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.171 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.170 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.169 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.167 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.166 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.165 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.164 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.163 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.162 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.161 tracks/mips/exercises/octal/example.mips
trackler-2.2.1.160 tracks/mips/exercises/octal/example.mips