1

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?

1
  • Just allocate some space on stack for the local variable, then you can read number, write to memory as per normal. Commented Aug 3, 2012 at 4:36

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

2 Comments

Then why does it say "local variables" ?
A temporary variable or register is a local variable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.