Reading and printing an integer in mips

前端 未结 2 1623
梦毁少年i
梦毁少年i 2020-12-30 15:48

My program is suppose to read an integer and print it back to the user but every time it just prints 268501230 no matter what is entered. Any help would be appreciated.

2条回答
  •  梦毁少年i
    2020-12-30 16:11

    This is how I will write a program to get an integer input and to print it out

    .data
    
         text:  .asciiz "Enter a number: "
    
    .text
    
     main:
        # Printing out the text
        li $v0, 4
        la $a0, text
        syscall
    
        # Getting user input
        li $v0, 5
        syscall
    
        # Moving the integer input to another register
        move $t0, $v0
    
        # Printing out the number
        li $v0, 1
        move $a0, $t0
        syscall
    
        # End Program
        li $v0, 10
        syscall
    

提交回复
热议问题