CSE/EEE 230 Assignment 2
Part 1:
In this part of the assignment, you are to make changes to the following program:
# Assignment 2 Part 1
# Debra Calliss
#
# Program will prompt for an integer and then print the numbers from 1
# to the input number.
.data
prompt:
.asciiz "Enter in an integer: "
newline:.asciiz "\n"
.globl main
.text
main:
move
$s7, $ra
#save the return address in a register
# prompt for input
li
$v0, 4
# set command to print string
la
$a0, prompt
# set string to print
syscall
# print prompt
# read in the number
li
$v0, 5
# set command to read integer
syscall
# call to read integer
move
$s0, $v0
# save the number
# initialize loop
li
$t1, 0
# set loop counter to 0
# while loop counter != number
top:
beq
$t1, $s0, end # compare loop counter and integer
# increment counter
addi
$t1, $t1, 1
# add 1 to counter
# print counter value and new line
li
$v0, 1
# set command to print integer
move
$a0, $t1
# set integer to print
syscall
# print counter
li
$v0, 4
# set command to print string
la
$a0, newline
# set newline to print
syscall
# print newline
# bottom of loop
j
top
# repeat

This preview has intentionally blurred sections.
Sign up to view the full version.

This is the end of the preview.
Sign up
to
access the rest of the document.
- Fall '09
- DebraCaliss
- #, Control flow, Debra Calliss
-
Click to edit the document details