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

  • Home
  • SEARCH
  • 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 8337857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:24:54+00:00 2026-06-09T04:24:54+00:00

I am trying to write a function to copy words from source memory to

  • 0

I am trying to write a function to copy words from source memory to destination memory.

I have written the function but I am having difficulty executing the code.
It is giving me execption 4 as an error

.data    
.text      
main:

.setnoreorder      
top: beq $a2,0,done 
lw $t1,($a0) 
sw $t1,($a1) 
add $a0,$a0,4 
add $a1,$a1,4 
j top     
sub $a2,$a2,1


done:   
jr  $ra     #return to the main program 
add $0, $0, $0  #nop 

I want to write a main program which calls this function to copy 800 words from
address 0x50000 to 0x90000 in memory. But when I add the values in $a0-$a2 and run the code it doesnt work.
Does anyone know how to fix it. (I am converting C code to MIPS which is why I have included a C tag

Cheers

  • 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-06-09T04:24:55+00:00Added an answer on June 9, 2026 at 4:24 am
        .text                       # code starts here 
    main:                           # required label
        la      $a0,dest            # point to destination
        la      $a1,srce            # point to source
        li      $a2,1000            # move this many words 
        jal     block_copy          # call the routine 
        nop
        li      $v0,10
        syscall
    
    ###############################################################################
    #   block copy - moves $a3 words from $a1 to $a0
    #
    #   register usage:
    #       $a0 address of destination 
    #       $a1 address of source
    #       $a2 block size (number of words to move)
    #       $v0 return code (0 means no troubles)
    #
    block_copy:
    
        move        $v0,$a2         # counter/rc 
    bc_loop:
        lw          $t0,0($a1)      # no DMA here
        sw          $t0,0($a0)      # we have to move a word at a time 
        addiu       $a0,$a0,4       # point to next word in destination
        addiu       $a1,$a1,4       # point to next word in source
        addiu       $v0,$v0,-1      # decrement counter 
        bgtz        $v0,bc_loop     # keep on moving if counter is positive 
        jr          $ra             # return to caller
    ###############################################################################
    
        .data 
    dest:
        .word       9:1000          # destination 1000 words (all zeroes)
    srce:
        .word       0:1000          # source 1000 words (all nines)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying copy some words from memory and saving it to another memory
I'm trying to write a jquery funciton that will copy specified fields from the
I am trying write a function that generates simulated data but if the simulated
I am trying to write the following function in C, char* modelstrdup(char* source); The
I am trying to write a VB function to strip unwanted characters from a
I'm trying to create a copy to clipboard IE javascript function but my code
I'm trying to write function to do the number_format() job for the non-ascii numbers
Trying to write a function to see how often an object exists and give
Im trying to write a function for adding category: function addCategory() { $cname =
I am trying to write a function to determine if a string is a

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.