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
kjc015
CSCI206-S21-62
Commits
14f2a283
Commit
14f2a283
authored
Mar 21, 2021
by
kjc015
Browse files
Lab 06, Complete
parent
868565cc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Labs/Lab06/Makefile
View file @
14f2a283
all
:
collatz
CC
=
gcc
CFLAGS
=
-Wall
-Werror
CC
=
gcc
CFLAGS
=
-g
-Wall
-Werror
EXE
=
collatz
all
:
$(EXE)
collatz
:
collatz.o
$(CC)
$(CFLAGS)
collatz.o
-o
collatz
<tab>$(CC)
-o
collatz
collatz.o
collatz.o
:
collatz.c
<tab>$(CC)
$(CFLAGS)
-c
collatz.c
-o
collatz.o
Labs/Lab06/collatz.s
0 → 100644
View file @
14f2a283
#
Student
name
:
Kyle
Chrysler
#
#
#
This
program
uses
two
different
procedures
,
collatz
and
find
length
,
to
compute
the
#
Collatz
procedure
.
#
.
data
printString
:
.
asciz
" ==> "
ivar
:
.
word
1
return
:
.
asciz
"\n"
.
text
main
:
li
s1
,
100
#
Max
values
la
t1
,
ivar
#
Keep
track
of
i
variable
lw
s2
,
0
(
t1
)
jal
loop
loop
:
beq
s2
,
s1
,
exit
#
If
it
reaches
max
value
,
go
to
exit
condition
mv
a0
,
s2
#
Move
i
to
be
printed
li
a7
,
1
ecall
la
a0
,
printString
li
a7
,
4
ecall
mv
s4
,
s2
#
s4
is
value
used
in
find
length
computations
(
n
)
j
findlength
back
:
mv
a0
,
s3
#
storing
count
in
a0
to
be
printed
li
a7
,
1
ecall
la
a0
,
return
#
printing
a
new
line
li
a7
,
4
ecall
addi
s2
,
s2
,
1
#
increment
i
j
loop
findlength
:
li
t0
,
1
li
s3
,
1
bgt
s4
,
t0
,
while
#
jump
to
while
if
your
n
is
not
1
while
:
li
t0
,
1
ble
s4
,
t0
,
back
#
if
n
is
1
,
return
and
print
it
out
addi
s3
,
s3
,
1
#
increment
our
count
since
it
was
not
1
j
collatz
collatz
:
li
t3
,
0
li
t1
,
1
li
t2
,
2
beq
s4
,
t1
,
one
#
jump
to
my
condition
where
n
is
one
rem
t4
,
s4
,
t2
#
check
remainder
of
n
beq
t4
,
t3
,
even
#
jump
to
even
case
beq
t4
,
t1
,
odd
#
jump
to
odd
case
one
:
li
s4
,
1
#
make
n
value
1
j
back
even
:
li
t0
,
2
div
s4
,
s4
,
t0
#
divide
current
n
value
by
2
j
while
odd
:
li
t0
,
3
mul
t1
,
s4
,
t0
#
compute
3
n
addi
s4
,
t1
,
1
#
compute
3
n
+
1
j
while
exit
:
li
a7
,
10
ecall
\ No newline at end of file
Labs/Lab06/xfind.s
View file @
14f2a283
...
...
@@ -125,7 +125,7 @@ main:
#
call
to
xfind
li
a7
,
34
li
a7
,
34
#
printing
out
hex
value
ecall
...
...
@@ -143,14 +143,14 @@ xfind:
# if found, return the address of the first match
# if not found, return 0 (NULL)
lb
t2
,
0
(
a0
)
beq
t2
,
a1
,
exit
beq
t2
,
zero
,
exitNull
addi
a0
,
a0
,
1
lb
t2
,
0
(
a0
)
#
load
the
first
character
of
the
string
into
t2
beq
t2
,
a1
,
exit
#
branch
if
the
character
is
found
beq
t2
,
zero
,
exitNull
#
branch
if
we
reach
the
end
of
the
string
(
null
character
)
addi
a0
,
a0
,
1
#
increment
to
next
character
in
string
j
xfind
exitNull
:
li
a0
,
0
li
a0
,
0
#
load
null
character
(
0
)
into
exit
:
jr
ra
jr
ra
#
return
to
original
function
call
Write
Preview
Supports
Markdown
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