Monash University > School of Computer Science and Software Engineering > CSE1303 > Part B > Lectures > Lecture B09 notes

CSE1303 Computer Science
Semester 3 (summer), 2003
Part B
Lecture B09 notes: MIPS instructions

In this lecture

Listings

Slide 31

# Program to convert inches to millimetres.
# Integer approximation, multiply by 254/10.

        # Data used by the program
        .data
inch:   .word 42          # Allocate word, store value 42
mm:     .space 4          # Allocate word, value unimportant 

        # Program starts from label main.
        .text
main:   lw $t0, inch          # get inches into $t0
        mulu $t1, $t0, 254    # multiply...
        divu $t2, $t1, 10     # ...and divide
        sw $t2, mm            # store result in mm

        li $v0, 10            # system call 10...
        syscall               # ...exits simulation

[ Top | Home ]

Last modified 2002-12-05