0% found this document useful (0 votes)
27 views

SVU CE450 Spring 2015 Homework #3 Due Date: in Two Week

This document provides instructions for Homework #3 that is due in two weeks. Students are asked to write a MIPS assembly program that counts the characters in a string and prints the count using syscall. The string should contain the student's full name. Students should include the assembly program that counts the characters in the string "Kongara Jalandhar" and prints the count of 17. A screenshot of running the program in MARS simulator is also required.

Uploaded by

Srikanth Vuduta
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views

SVU CE450 Spring 2015 Homework #3 Due Date: in Two Week

This document provides instructions for Homework #3 that is due in two weeks. Students are asked to write a MIPS assembly program that counts the characters in a string and prints the count using syscall. The string should contain the student's full name. Students should include the assembly program that counts the characters in the string "Kongara Jalandhar" and prints the count of 17. A screenshot of running the program in MARS simulator is also required.

Uploaded by

Srikanth Vuduta
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

SVU CE450 Spring 2015

Homework #3
Due date: in two week.
Answer Sheet: Student ID: 150101075, Student Name: Kongara Jalandhar
In this homework, you are to write a MIPS assembly program and run the simulation on the
SimulatorsMARS, with detailed steps as below:

1. Write a MIPS assembly program to count the number of characters in a string, and report the
count thru syscall print function.
.data
string:

.asciiz "Hello CA1 Class"

.text
.globl Values
Values:
li
$s0, 0
# length = 1
la
$s1, string
# $s1 = string
Loop:
lb
$s2, 0($s1)
# pointer to the first letter
beqz $s2, done
# if length is zero stop the program
addi $s0, $s0, 1
# length = length + 1
addi $s1, $s1, 1
# pointer incrementing
j
Loop
done:
li
$v0, 1
# syscall code: print_int
move $a0, $s0
syscall

2. The string shall contain your full name starting from firstname, followed by middle name, and
ends with your last name. e.g. John Junior Smith
# part of the assembly program should contains the string as follows.
.data
.align 4
string: .asciiz "Kongara Jalandhar"
.text
.globl main
main:
li
la
syscall

$v0, 4
$a0, string

li
$v0,10
syscall

3. The program ce450_student_id_hw3.asm that counts the number of characters of the


exemplar string above, and print out the value using syscall. (student_id is the your student
id number). In the example above, the value should be 17.
Include the assembly program below as your answer.
.data
.align 4
string: .asciiz "Kongara Jalandhar"
.text
.globl Values
Values:
li
$s0, 0
# length = 1
la
$s1, string
# $s1 = string
Loop:
lb
$s2, 0($s1)
# pointer to the first letter
beqz $s2, done
# if length is zero stop the program
addi $s0, $s0, 1
# length = length + 1
addi $s1, $s1, 1
# pointer incrementing
j
Loop
done:
li
$v0, 1
# syscall code: print_int
move $a0, $s0
syscall

4. Take a screen shot and print a hard copy attached. . Fuzzy or unclear screen capture is not
acceptable and will render zero mark on the report. Screen capture should include the title bar
to show a unique directory to authenticate the students uniqueness computer, similar screen
captures will be asked to demonstrate in the class.

You might also like