how to pass a list to a function without using move in mipsmips program that finds how many times a character appears in a specific stringMIPS subroutine passing parameters by referenceMars Mips , how to represent struct and listMIPS function with multiple argumentsHow to implement NOT operation in MIPS?Trouble with simple Mips functionMIPS - Moving graphsMove a graph within a certain range - MIPSMIPS swap functionC to MIPS - functions and arrays
Is it double speak?
Why can I log in to my Facebook account with a misspelled email/password?
Can ads on a page read my password?
Capacitors with a "/" on schematic
Decode a variable-length quantity
Is it allowed and safe to carry a passenger / non-pilot in the front seat of a small general aviation airplane?
What are the examples (applications) of the MIPs in which the objective function has nonzero coefficients for only continuous variables?
Erratic behavior by an internal employee against an external employee
Short story about a teenager who has his brain replaced with a microchip (Psychological Horror)
In the movie Harry Potter and the Order or the Phoenix, why didn't Mr. Filch succeed to open the Room of Requirement if it's what he needed?
Braces spanning multiple tables (whole tables, not rows or pages)
Validation and verification of mathematical models
Is this cheap "air conditioner" able to cool a room?
French equivalent of "Make leaps and bounds"
What are good ways to improve as a writer other than writing courses?
HttpResponse[Status=BAD_REQUEST, StatusCode=400]
How would a family travel from Indiana to Texas in 1911?
Does the length of a password for Wi-Fi affect speed?
Should I self-publish my novella on Amazon or try my luck getting publishers?
Why do private jets such as Gulfstream fly higher than other civilian jets?
Need help understanding lens reach
Can I enter a rental property without giving notice if I'm afraid a tenant may be hurt?
How to avoid ci-driven development..?
Are certificates without DNS fundamentally flawed?
how to pass a list to a function without using move in mips
mips program that finds how many times a character appears in a specific stringMIPS subroutine passing parameters by referenceMars Mips , how to represent struct and listMIPS function with multiple argumentsHow to implement NOT operation in MIPS?Trouble with simple Mips functionMIPS - Moving graphsMove a graph within a certain range - MIPSMIPS swap functionC to MIPS - functions and arrays
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
i want to pass a list to function in mips so that i can do soemthing to that lsit, but my assignment prohibit the move instruction,
tried to pass the address, but they all error
addi $fp, $sp, 0
addi $sp, $sp, -4
la $t0, thelist
sw $t0, ($sp)
jal bubblesort
bubblesort:
#call function
addi $sp, $sp, -8 #push 8 bytes to store $fp and $ra
sw $ra, 4($sp)
sw $fp, ($sp)
#copy $sp to $fp
addi $fp, $sp, 0
#allocate local variable
addi $sp, $sp, -16 #i, j, listaddress, size
#initialize i j n
lw $t0, 8($fp)
sw $t0, -12($fp) # listaddress
lw $t1, size
sw $0, -8($fp) #i = 0
sw $0, -4($fp) #j = 0
loop1:
#condition
lw $t0, -8($fp) #load i
lw $t1, size #the actual n
addi $t1, $t1, -1 #n = n - 1
beq $t0, $t1, end #if i == n-1, jump to end
loop2:
lw $t0, -4($fp) #load j
lw $t1, size #load n
addi $t1, $t1, -1 #n = n - 1
beq $t0, $t1, exit1 #if j == n-1, jump to exit1
#swap section
lw $t1, thelist #$t1 = list address
sll $t0, $t0, 2 #j = j*4
add $t3, $t1, $t0 #address of list[j]
lw $t4, ($t3) #list[j]
lw $t5, 4($t3) #list[j+1]
slt $t2, $t5, $t4
beq $t2, $0, exit2 #if list[j] < list[j+1], jump to loop2
#swap
add $t2, $t5, 0 #temp = list[j+1]
add $t5, $t4, 0 #list[j+1] = list[j]
add $t4, $t2, 0 #list[j] = temp
sw $t5, ($t3)
sw $t6, 4($t3)
lw $t0, -4($fp)
addi $t0, $t0, 1 #j = j+1
sw $t0, -4($fp)
j loop2
exit2:
lw $t0, -4($fp)
addi $t0, $t0, 1 #j = j+1
sw $t0, -4($fp)
j loop2
exit1:
lw $t0, -8($fp)
addi $t0, $t0, 1
sw $t0, -8($fp)
j loop1
end:
lw $v0, -12($fp)
addi $sp, $sp 12
lw $fp, ($sp)
lw $ra, 4($sp)
addi $sp, $sp, 8
jr $ra
mips32
add a comment |
i want to pass a list to function in mips so that i can do soemthing to that lsit, but my assignment prohibit the move instruction,
tried to pass the address, but they all error
addi $fp, $sp, 0
addi $sp, $sp, -4
la $t0, thelist
sw $t0, ($sp)
jal bubblesort
bubblesort:
#call function
addi $sp, $sp, -8 #push 8 bytes to store $fp and $ra
sw $ra, 4($sp)
sw $fp, ($sp)
#copy $sp to $fp
addi $fp, $sp, 0
#allocate local variable
addi $sp, $sp, -16 #i, j, listaddress, size
#initialize i j n
lw $t0, 8($fp)
sw $t0, -12($fp) # listaddress
lw $t1, size
sw $0, -8($fp) #i = 0
sw $0, -4($fp) #j = 0
loop1:
#condition
lw $t0, -8($fp) #load i
lw $t1, size #the actual n
addi $t1, $t1, -1 #n = n - 1
beq $t0, $t1, end #if i == n-1, jump to end
loop2:
lw $t0, -4($fp) #load j
lw $t1, size #load n
addi $t1, $t1, -1 #n = n - 1
beq $t0, $t1, exit1 #if j == n-1, jump to exit1
#swap section
lw $t1, thelist #$t1 = list address
sll $t0, $t0, 2 #j = j*4
add $t3, $t1, $t0 #address of list[j]
lw $t4, ($t3) #list[j]
lw $t5, 4($t3) #list[j+1]
slt $t2, $t5, $t4
beq $t2, $0, exit2 #if list[j] < list[j+1], jump to loop2
#swap
add $t2, $t5, 0 #temp = list[j+1]
add $t5, $t4, 0 #list[j+1] = list[j]
add $t4, $t2, 0 #list[j] = temp
sw $t5, ($t3)
sw $t6, 4($t3)
lw $t0, -4($fp)
addi $t0, $t0, 1 #j = j+1
sw $t0, -4($fp)
j loop2
exit2:
lw $t0, -4($fp)
addi $t0, $t0, 1 #j = j+1
sw $t0, -4($fp)
j loop2
exit1:
lw $t0, -8($fp)
addi $t0, $t0, 1
sw $t0, -8($fp)
j loop1
end:
lw $v0, -12($fp)
addi $sp, $sp 12
lw $fp, ($sp)
lw $ra, 4($sp)
addi $sp, $sp, 8
jr $ra
mips32
add a comment |
i want to pass a list to function in mips so that i can do soemthing to that lsit, but my assignment prohibit the move instruction,
tried to pass the address, but they all error
addi $fp, $sp, 0
addi $sp, $sp, -4
la $t0, thelist
sw $t0, ($sp)
jal bubblesort
bubblesort:
#call function
addi $sp, $sp, -8 #push 8 bytes to store $fp and $ra
sw $ra, 4($sp)
sw $fp, ($sp)
#copy $sp to $fp
addi $fp, $sp, 0
#allocate local variable
addi $sp, $sp, -16 #i, j, listaddress, size
#initialize i j n
lw $t0, 8($fp)
sw $t0, -12($fp) # listaddress
lw $t1, size
sw $0, -8($fp) #i = 0
sw $0, -4($fp) #j = 0
loop1:
#condition
lw $t0, -8($fp) #load i
lw $t1, size #the actual n
addi $t1, $t1, -1 #n = n - 1
beq $t0, $t1, end #if i == n-1, jump to end
loop2:
lw $t0, -4($fp) #load j
lw $t1, size #load n
addi $t1, $t1, -1 #n = n - 1
beq $t0, $t1, exit1 #if j == n-1, jump to exit1
#swap section
lw $t1, thelist #$t1 = list address
sll $t0, $t0, 2 #j = j*4
add $t3, $t1, $t0 #address of list[j]
lw $t4, ($t3) #list[j]
lw $t5, 4($t3) #list[j+1]
slt $t2, $t5, $t4
beq $t2, $0, exit2 #if list[j] < list[j+1], jump to loop2
#swap
add $t2, $t5, 0 #temp = list[j+1]
add $t5, $t4, 0 #list[j+1] = list[j]
add $t4, $t2, 0 #list[j] = temp
sw $t5, ($t3)
sw $t6, 4($t3)
lw $t0, -4($fp)
addi $t0, $t0, 1 #j = j+1
sw $t0, -4($fp)
j loop2
exit2:
lw $t0, -4($fp)
addi $t0, $t0, 1 #j = j+1
sw $t0, -4($fp)
j loop2
exit1:
lw $t0, -8($fp)
addi $t0, $t0, 1
sw $t0, -8($fp)
j loop1
end:
lw $v0, -12($fp)
addi $sp, $sp 12
lw $fp, ($sp)
lw $ra, 4($sp)
addi $sp, $sp, 8
jr $ra
mips32
i want to pass a list to function in mips so that i can do soemthing to that lsit, but my assignment prohibit the move instruction,
tried to pass the address, but they all error
addi $fp, $sp, 0
addi $sp, $sp, -4
la $t0, thelist
sw $t0, ($sp)
jal bubblesort
bubblesort:
#call function
addi $sp, $sp, -8 #push 8 bytes to store $fp and $ra
sw $ra, 4($sp)
sw $fp, ($sp)
#copy $sp to $fp
addi $fp, $sp, 0
#allocate local variable
addi $sp, $sp, -16 #i, j, listaddress, size
#initialize i j n
lw $t0, 8($fp)
sw $t0, -12($fp) # listaddress
lw $t1, size
sw $0, -8($fp) #i = 0
sw $0, -4($fp) #j = 0
loop1:
#condition
lw $t0, -8($fp) #load i
lw $t1, size #the actual n
addi $t1, $t1, -1 #n = n - 1
beq $t0, $t1, end #if i == n-1, jump to end
loop2:
lw $t0, -4($fp) #load j
lw $t1, size #load n
addi $t1, $t1, -1 #n = n - 1
beq $t0, $t1, exit1 #if j == n-1, jump to exit1
#swap section
lw $t1, thelist #$t1 = list address
sll $t0, $t0, 2 #j = j*4
add $t3, $t1, $t0 #address of list[j]
lw $t4, ($t3) #list[j]
lw $t5, 4($t3) #list[j+1]
slt $t2, $t5, $t4
beq $t2, $0, exit2 #if list[j] < list[j+1], jump to loop2
#swap
add $t2, $t5, 0 #temp = list[j+1]
add $t5, $t4, 0 #list[j+1] = list[j]
add $t4, $t2, 0 #list[j] = temp
sw $t5, ($t3)
sw $t6, 4($t3)
lw $t0, -4($fp)
addi $t0, $t0, 1 #j = j+1
sw $t0, -4($fp)
j loop2
exit2:
lw $t0, -4($fp)
addi $t0, $t0, 1 #j = j+1
sw $t0, -4($fp)
j loop2
exit1:
lw $t0, -8($fp)
addi $t0, $t0, 1
sw $t0, -8($fp)
j loop1
end:
lw $v0, -12($fp)
addi $sp, $sp 12
lw $fp, ($sp)
lw $ra, 4($sp)
addi $sp, $sp, 8
jr $ra
mips32
mips32
edited Mar 27 at 6:06
Stefan Becker
4,5913 gold badges11 silver badges25 bronze badges
4,5913 gold badges11 silver badges25 bronze badges
asked Mar 27 at 5:26
LeslieLeslie
1
1
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You actually can access $t registers inside your functions. There is no need to store it on the stack before. If you load your list to $t10 for example, you can easily access it inside of your function. Also: Instead of move, you can always use add. I can't run your code, since it is not a complete example. How is your list stored?
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55370331%2fhow-to-pass-a-list-to-a-function-without-using-move-in-mips%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You actually can access $t registers inside your functions. There is no need to store it on the stack before. If you load your list to $t10 for example, you can easily access it inside of your function. Also: Instead of move, you can always use add. I can't run your code, since it is not a complete example. How is your list stored?
add a comment |
You actually can access $t registers inside your functions. There is no need to store it on the stack before. If you load your list to $t10 for example, you can easily access it inside of your function. Also: Instead of move, you can always use add. I can't run your code, since it is not a complete example. How is your list stored?
add a comment |
You actually can access $t registers inside your functions. There is no need to store it on the stack before. If you load your list to $t10 for example, you can easily access it inside of your function. Also: Instead of move, you can always use add. I can't run your code, since it is not a complete example. How is your list stored?
You actually can access $t registers inside your functions. There is no need to store it on the stack before. If you load your list to $t10 for example, you can easily access it inside of your function. Also: Instead of move, you can always use add. I can't run your code, since it is not a complete example. How is your list stored?
edited Mar 28 at 21:40
answered Mar 28 at 21:35
KruspeKruspe
268 bronze badges
268 bronze badges
add a comment |
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55370331%2fhow-to-pass-a-list-to-a-function-without-using-move-in-mips%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown