简体   繁体   中英

Input Integers in MIPS Assembly

I am writing a program in MIPS that will read in signed integers from the keyboard.

Is there a way to read input like that, the way we do in higher level languages from a console? If not, I already have an array as follows:

          .data
intdata:  .word  3, 23, -5, 57, -12, 41, 39, -43, 40, 30     # input of integers

Can I operate on the array without knowing its length? So loop until at the end of the array. Or should I put another argument which holds the length of the array?

This is assembly, you don't have such high level functions. Most simulators do, however, offer some functionality to read/write through I/O. This is done through syscalls. You should read the simulator's documentation, or tell us what simulator you're using (if using any).

You can't operate with an array without knowing its length. You say "loop until the end of the array", but what's the end of the array? How would you know when programming? You have two basic solutions for this: either use another variable that holds array length or you use an end of array marker (a value that will let you know when the array has ended).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM