Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7610853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:31:10+00:00 2026-05-31T01:31:10+00:00

So I am debugging some code and keep getting a weird result. I am

  • 0

So I am debugging some code and keep getting a weird result. I am looping through a array and printing each element to the console. After I print each element I want to print a string that consist of only the “\n” , newline character. I run the code in QtSpim. When I do it print the new line AND the next string, str3 . I just want it to print str2 so I have the next element ready to print on a new line. Anyone run into a problem like this or see anything wrong with my code.

Problem is with second syscall in print_sorted_data function

.data        
    x:    .word  1,2,3,4,5,6,7,8  #OR  x: .space 32   #since x contains 8 words,we have to reserve 32 bytes.    
    min:  .word  0
    max:  .word  0
    mean: .word  0  
    str1: .ascii "\n The Min, Max and Mean of the array are : \n "  

    str2: .ascii " \n"

    str3: .ascii "Enter Number: \n"

.text  
#======================================================================= 
main: 
#======================================================================= 

    #Push $ra into stack 
addi $sp, $sp, -4
sw $ra, 0($sp)

#-------------------------------------------------------------------
#***jal read_data 
#***nop  
#-------------------------------------------------------------------

la $a0, x
ori $a1, $0, 8

#-------------------------------------------------------------------
jal print_sorted_data   
nop
#-------------------------------------------------------------------




jr $ra
nop

#======================================================================= 
read_data:  
#======================================================================= 
    #reading data from console , storing it in memory
    #initialization for the counter of the loop

addi $t1, $0, 0     ## $t1<-stores counter for loop.

## don't need addi $t2, $0, 8        ## max value of loop

#lodad The base adderss of array 
la $t0, x

check_cond1: ##############################
        #check condition of the loop, if not met branch to read_done

slti $t3, $t1, 8
beq  $t3, $0, read_done1
nop

        #read an int from console and store it in &x[i]

ori $v0, $0, 4  ## print " enter number" to screen
la $a0, str3   ## changed lw to la
syscall

ori $v0, $0, 5
syscall
sw $v0, 0($t0)

    #update both counter of the loop and pointer to the next element in the array

addi $t1, $t1, 1
addi $t0, $t0, 4

j check_cond1
nop

read_done1: 
jr $ra  
nop

#=======================================================================
#printing the sorted data
print_sorted_data:
#=======================================================================
    #initialization for the counter of the loop
    #lodad The base adderss of array 

ori $t9, $a0, 0 ##  We get base address in $a0
ori $t0, $0, 0 ##counter for loop


check_cond2: ##############################
        #check condition of the loop, if not met branch to print_done1

slt $t1, $t0, $a1
beq $t1,$0, print_done1

    #print x[i]
sll $t2,$t0 ,2 ## Multiply counter by 4 for offset
add $t2, $t2, $t9 ## Add to base address

ori $v0, $0, 1 ## set syscall up to print integer
lw $a0, 0($t2)
syscall  ## not sure if this is right func name## it is

    #go to next line by printing "\n"

ori $v0, $0, 4 ## set syscall up to print string
la $a0, str2
syscall



    #update both counter of the loop and pointer to the next element in the array
##Dont think i have to update array. It does that in the loop.

add $t0, $t0, 1

j check_cond2
nop 

print_done1: #######################
jr $ra  
nop 

**Upon further investigation .ascii should be .asciiz Anyone know the difference?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:31:12+00:00Added an answer on May 31, 2026 at 1:31 am

    The difference is the trailing zero after the string given with .asciiz. Basically its almost the same as .ascii, it only appends a 0 char, which serves as terminating char for the string.

    So if you use .ascii and don’t manually specify a terminating 0, the string gets merged with the following data in memory – the \n is not a string termination (only a line termination).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm debugging some code, which is going to result in me constantly logging in
I am debugging some code and have encountered the following SQL query (simplified version):
I am debugging some code and I want to find out when a particular
In Eclipse (Ganymede) I'm debugging some code that uses Apache Commons HttpClient and would
I'm very busy write now debugging some code, so I can't cookup a complete
I have some debugging code that if executed while running with GBD attached should
Debugging some finance-related SQL code found a strange issue with numeric(24,8) mathematics precision. Running
I have some code in MS VC++ 6.0 that I am debugging. For some
I'm currently debugging some fairly complex persistence code, and trying to increase test coverage
I am debugging some code, and would like to throw an error without actually

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.