Fahrenheit to Celsius

download Fahrenheit to Celsius

of 1

Transcript of Fahrenheit to Celsius

  • 8/8/2019 Fahrenheit to Celsius

    1/1

    # Tushar Shah CS 502

    # Fahrenheit to Celsius

    # Required Information.# 1.At least one instruction from each instruction type: R-type arithmetic, I-type arithmetic and Memory transfer.# 2.Input and output through system calls.# 3.Comments explaining the format and the meaning of each instruction.

    # Tested using the SPIM MIPS simulator

    .text

    .globl __start

    __start: # execution starts herela $a0, line # print line1 on terminalli $v0, 4 # load number4 into register $v0, I-Type

    Arithmeticsyscall # syscal code

    li $v0, 5 # read from usersyscall #

    #

    sub $t0, $v0, 32 # $to = $vo - 32, sub 32,R-Type Arithmetic

    div $t1, $t0, 9 # $t1 = $to / 9, divide by 9, R-type Arithmetic

    mul $t2, $t1, 5 # $t2 = $V1 * 5, multiply by 5, R-type Arithmetic

    la $a0, ans # print lineli $v0, 4syscall

    move $a0, $t2 # print resultli $v0, 1syscall

    la $a0, endl # system call to printli $v0, 4 # out a newlinesyscall

    li $v0, 10 # exit programsyscall

    .data # data segmentline: .asciiz "Enter Temperature in Fahrennheit: "ans: .asciiz "The Temperature in Celsius is: "endl: .asciiz "\n"

    #THE END