954,490 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how does syscall 5 work?

ok i know this is the command for reading an integer but where does it read the integer from? I got a factorial program, heres the beginning of it:

.data
prompt: .asciiz "you want n! for which value of n?\n"
.align 4
n: .space4
i: .word 1
fact: .word 1

.text
.globl main

main:
li $v0, 4 #syscall code: print string
la $a0, prompt
syscall
li $v0, 5 #syscall code: read int
syscall
sw $v0, n

from my understanding, the program is meant to prompt u for a number and u enter a number and then the read int function will read tht integer and store it to address n. But how do i enter this number? i tried running this on SPIM(simulator for MIPS) and it just came out with a 0 everytime because apparently the read int is reading a 0?

ssDimensionss
Newbie Poster
21 posts since May 2008
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You