The first two questions in this week's prac are designed to show you the result of typical annoying errors that can arise and what to notice when debugging. You should work through them pretty quickly.
mispelt-label.s,
which has one of the labels in the source mispelt.
Assemble, link and run this program.
as-isem,
if any?
ld-isem,
if any?
tkisem,
if any? Check the window you started tkisem in also.
unaligned-access.s,
which is supposed to loop through a string (doing nothing), but uses
ld instead of ldub.
Assemble, link and run this program.
Run it and notice what happens. Remember this to help you debug!
.align 4 arry: .word 2, 5, 8, 13, 17, 21 size: .word 6 result: .wordin your
.data section, and write your answer to
result.
Your code should work for any (reasonably sized) array, from 0 entries up to as many as you can fit in memory and add up without overflowing a 32 bit signed word.
For example, if the input word is 19, your result should be 3, since 19 = 10011 in binary, and this contains 3 ones.
msg: .asciz "Buy me a pony"your program should print
ynop a em yuBYou should print your string using trap 6 (i.e. not just printing it one character at a time).
For bonus pride, do it without using any extra memory.
Write a SPARC program which reads the word value of the memory location
labelled n, and prints the value of the nth fibonacci
number. For this exercise, do not use recursion. Run your program to
calculate the 30th Fibonacci number and note the number of cycles required.
Comp226 August 2013