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.0.0.5 tracks/mips/exercises/octal/example.mips
trackler-2.0.0.4 tracks/mips/exercises/octal/example.mips
trackler-2.0.0.3 tracks/mips/exercises/octal/example.mips
trackler-2.0.0.2 tracks/mips/exercises/octal/example.mips
trackler-2.0.0.1 tracks/mips/exercises/octal/example.mips
trackler-2.0.0.0 tracks/mips/exercises/octal/example.mips
trackler-1.0.4.1 tracks/mips/exercises/octal/example.mips
trackler-1.0.4.0 tracks/mips/exercises/octal/example.mips
trackler-1.0.3.0 tracks/mips/exercises/octal/example.mips
trackler-1.0.2.1 tracks/mips/exercises/octal/example.mips
trackler-1.0.2.0 tracks/mips/exercises/octal/example.mips
trackler-1.0.1.2 tracks/mips/exercises/octal/example.mips
trackler-1.0.1.1 tracks/mips/exercises/octal/example.mips
trackler-1.0.1.0 tracks/mips/exercises/octal/example.mips
trackler-1.0.0.1 tracks/mips/exercises/octal/example.mips
trackler-1.0.0 tracks/mips/exercises/octal/example.mips