Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Courses
csci206_lecture_examples
Commits
e390c7d3
Commit
e390c7d3
authored
Feb 17, 2014
by
Alan Marchiori
Browse files
added
parent
b809aa4a
Changes
1
Hide whitespace changes
Inline
Side-by-side
section01/Lec15/fact_localvar.s
0 → 100644
View file @
e390c7d3
.
text
main
:
li
$a0
,
10
jal
fact
move
$s0
,
$v0
li
$v0
,
10
syscall
#
exit
fact
:
addi
$sp
,
$sp
,
-
12
#
allocate
stack
sw
$ra
,
4
(
$sp
)
sw
$a0
,
0
(
$sp
)
#
setup
stack
,
8
(
$sp
)
is
un
-
initialized
ble
$a0
,
1
,
L1
#
if
a0
<=
1
,
goto
L1
# else recurse
addi
$a0
,
$a0
,
-
1
jal
fact
#
find
fact
(
a0
-
1
)
lw
$a0
,
0
(
$sp
)
#
get
our
a0
back
mul
$t0
,
$v0
,
$a0
#
t0
=
a0
*
fact
(
a0
-
1
)
sw
$t0
,
8
(
$sp
)
#
store
t0
into
our
local
variable
on
the
stack
j
return
L1
:
li
$t0
,
1
#
setup
a
register
with
1
sw
$t0
,
8
(
$sp
)
#
store
1
into
our
local
variable
#
fall
through
to
the
return
return
:
lw
$v0
,
8
(
$sp
)
#
load
return
value
from
the
local
variable
lw
$ra
,
4
(
$sp
)
#
load
the
return
address
addi
$sp
,
$sp
,
12
#
pop
stack
jr
$ra
#
return
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment