Aakash Anuj
Aakash Anuj

Reputation: 3871

MIPS : Storing integers or integer arrays as local variables

In a problem, I have been asked to use the concept of assigning integer variables as local variables in MIPS assembly language. which is. Write a program which (i) reads an integer in a local variable "inp" (with proper prompt)

What actually is meant by this assigning integer variables as local variables? and how do i go about this problem?

Upvotes: 1

Views: 11754

Answers (1)

Amir Afghani
Amir Afghani

Reputation: 38561

Read through the following tutorial. Part of this exercise is just invoking the right system routine:

The read_int, read_float and read_double services read an entire line of input up to and including the newline character.

As far as your question goes, it just means read the value the user enters into a variable (perhaps a register or a temp variable in your case).

Read integer value, store in RAM location with label int_value (presumably declared in data section)

    li  $v0, 5            # load appropriate system call code into register $v0;
                          # code for reading integer is 5
    syscall               # call operating system to perform operation
    sw  $v0, int_value    # value read from keyboard returned in register $v0;
                          # store this in desired location

Upvotes: 1

Related Questions