CO527 Anonymous Questions and Answers |
This page lists the various questions and answers. To submit a question, use the anonymous questions page. You may find the keyword index and/or top-level index useful for locating past questions and answers.
We have taken the liberty of making some minor typographical corrections to some of the questions as originally put. Although most of the questions here will have been submitted anonymously, this page also serves to answer some questions of general interest to those on the course.
Submission reference: IN448
What is the best method of checking if you have reached the last element of an array (the terminating 0 char) when iterating over it? If $a0 pointed to the last 'proper' element, and $a1 pointed to the terminating char, would this be sufficient ?:
beq $a1, 0x00, end #; jump out of loop (end of array)
Pretty much, yes. I'd be more inclined to use the $zero register for the comparison rather than constant 0x00 (although assemblers probably spot that and optimise it). Bear in mind that the end of either string could appear first, or both of them together. Since you're comparing strings (assuming this is the string, not the array of word-sized pointers to strings), the loop should probably stop when a character in one string is not the same as the corresponding character in the other, or when a null-terminating character is seen.
Keywords: mips-asm , mips-string-sorting
Submission reference: IN450
Hey, I am trying to compare two strings, if I have the two strings that I want to compare how do I go about looking through the characters of this string? Thanks
This has been covered fairly extensively in other questions; see Question 59 (2005), Question 51 (2005) and Question 39 (2005). An approximate implementation of string-comparison in C would be:
int strcmp (char *s1, char *s2) { int i = 0; for (i=0; (s1[i] == s2[i]) && (s1[i] != 0); i++); return (int)(s1[i] - s2[i]); }
There's an even simpler implementation, which has been hinted at in another anonymous question, but the above is what I'd consider "normal".
Keywords: mips-asm , mips-string-sorting
Submission reference: IN454
Hi, my program seems to sort the strings ok, but for some reason deletes the 'a' from 'all your MIPS assembler' and 'are belong to us', so my result is:
****************************** 0123456789 all your base all your base ll your MIPS assembler make your time re belong to us you have no chance to survive ******************************
I don't know why this is, I have no idea where there is a problem in my code so I would have to post all my code, which I don't want to do! Do you have any idea without seeing the code why this occurs? ie what kind of error in the code would cause it to delete these two (seemingly random) characters? Thanks!
That's a fairly strange one -- my guess would be that these are getting damaged early on in the sort (though that's not necessarily clear). Check the code that swaps two strings around in the array -- i.e. comment it out temporarily and see if the original list is still produced. If not, there's probably an error in the sort-loop itself; if so, then the swap is damaged. Also worth double-checking that your subroutines aren't trashing any values they shouldn't be (e.g. $s0-$s7).
Keywords: mips-asm , mips-string-sorting
Submission reference: IN457
I get this error when attempting to swap strings:
Exception occurred at PC=0x00400124 Unaligned address in store: 0x100100c1 Exception occurred at PC=0x00400120 Unaligned address in store: 0x10010109 Exception occurred at PC=0x004000c8 Unaligned address in inst/data fetch: 0x10010129 Exception occurred at PC=0x004000cc Unaligned address in inst/data fetch: 0x1001012d
Can you elaborate on the error at all? It doesn't make much sense to me. :/
It's because you're accessing a 16 or 32 bit value that isn't aligned on a 16 or 32 bit word (I'd guess a 32-bit load or store). The addresses should be useful: the "PC=0x00400124" is telling you at which point in your code the error occured -- you should see this somewhere in the spim/xspim code display -- scroll to it and on the right somewhere it should give you the source line-number in your assembly file. The address that failed (in store to start with) is 0x100100c1. This is badly aligned, but by looking at the data display you should be able to see which particular bit of data it was trying to access (which might not be what you expected, as it was chucking an exception).
There was a slight bug in the original code, although it wouldn't have caused a problem unless you changed the text in the strings at all (or added stuff in the data segment before the strings). Basically, after ".ascii" or ".asciiz" directives and before ".word" directives should be an ".align 4" directive. E.g.:
.data #; data segment s6: .asciiz "hello, mips world\n" .align 4 #; make sure words below are well-aligned strs: .word s6, 0
Keywords: mips-asm , mips-string-sorting
Submission reference: IN458
Is this the correct code for swapping the two strings?
sw $a1, 0($a2) sw $a0, 4($a2)
because it looks too simple but no other way works either, and I know there is a bug in my code when I swap and store the strings. P.S. can I also say thanks for spending so much time answering questions and late at night too!
That does look a bit too simple; the addresses given in the stores "0($a2)" and "4($a2)" probably shouldn't be like that -- if $a2 holds the address of some "array", that would store $a1 in array[0] and $a0 in array[1]. The array indices for the swap are variable (e.g. 'i' and 'j'). The code that does the swap would probably start in a similar way to the code that calls the string-comparison routine -- i.e. loading "strs[i]" and "strs[j]" into registers. Then it's mostly a case of storing them back, but in reverse -- there are various ways to write that in assembler, some simpler than others. The answer to Question 66 (2005) should be fairly helpful too.
Keywords: mips-asm , mips-string-sorting
Submission reference: IN473
Hey! Your giving an easier assesment to do? All my MIPS was in vein!! I'll get you for this one day!
Hopefully the compromise solution will be acceptable. After pondering options, there isn't a single way out which will make everyone happy, unfortunately. However, marks are not the only things you get out of assessments (knowledge and understanding gained, more experience of programming langauges and models, experience of using hardware simulators, ...). On the other hand, you're not likely to get any of these things out of a quiz, except knowledge that you need on-the-spot (e.g. peering at the text-books) and hopefully an improved understanding, but it's unlikely to teach you anything about programming, languages or systems (which was part of the point of the "programming assignment", as this was originally -- in the context of operating-systems).
Keywords: mips-asm
Submission reference: IN497
I managed to finish the mips but only with a bubble sort. Seeing as there is an extension, does this allow me to do an insertion sort(which is of order n and should get me the extra 20%)? Does insertion sort get us the extra marks?
Unless you were explicitly granted an extension (i.e. you asked for one, with the support of your tutor) you won't have one. However, an insertion sort may be order N, but that applies to inserting a single element in an already sorted array/list. If you start with an unsorted array/list, you still need to insert-sort each item into an initially empty array/list -- which gives order N*N. So nope, an insertion sort won't do.
Keywords: mips-asm
Submission reference: IN499
Hi,when will the MIPS online quiz be on webCT? Thanks
It'll be a little while yet, I still have to mark the MIPS and write the questions for the quiz; hopefully by week 22.
Keywords: mips-asm
Submission reference: IN504
Hi, is it possible to go over Java threading structure a bit more within this module since you already covered some aspects of threads and processes? I just thought it be easier to understand assembly if linked with java with hardware to software perspective.
In theory, yes. Although all the lectures slots this term have been planned, putting on an extra lecture is not much hastle (I have to write it, you have to turn up). But bear in mind that the gulf between Java and assembler is pretty massive. It's not entirely clear to me how knowing about Java threads would help assembler knowledge -- threading is not something you would want to do in assembler anyway ("threading" is really an application-level thing, but often there is a correspondence with the concurrency mechanisms in the OS). The mechanisms that the OS uses to manage concurrency (be it application threads, interrupts or multi-CPU stuff) tend to be small -- e.g. spinlocks. One of the recent assessment options was to implement the semaphore signal and wait algorithms, and that's probably about as far as I'd go! Indeed, as long as you've got spinlocks (assembler implementation with some way of calling from C), writing higher-level algorithms (semaphores, monitors, etc.) might better be done in C. The Linux kernel does most of this stuff in C -- spinlocks are in per-architecture assembler, of course.
Submission reference: IN505
Hi, any idea when we will get our essay marks back? I'd quite like to get a few coursework marks back before the strike!
I have done it all, but need to do some processing. Sorry about the delay - another module has been taking a LOT of my time.
You should get marks in the next few days.
Submission reference: IN525
When can we pick up our corrected assesment 1 essays? I went to the reception a couple times and they told me they haven't recived them.
In a couple of days, hopefully. See previous answer! Sorry about the delay- caused mainly by problems on another module.
Submission reference: IN546
Could you please tell me when we will be getting our marked essays back? It seems like a long time since we wrote the essays but to still have had no marks. Thank you
Please see the other two replies (it's a good idea to look there first...)
Submission reference: IN550
Where is this architecture assessment ? Has it been set yet or are we to wait for the WebCT part of the second assessment to set/done before we get the third assessment ?
The architecture assessment will be a WebCT test as well. It's essentially ready, but hasn't been fed into WebCT yet. The alternative second assessment (on WebCT) will be ready before too long, but I'm still writing questions for it. Sorry about the delay, but we're getting there as fast as possible; those who submitted the MIPS assembler have already had feedback.
Submission reference: IN551
Are the marks in the student data system correct? They currently say they're out of 100 but in the feedback the mark scheme suggested they'd be out of 20. I don't know whether I have 80% or 16%!!
If you're referring to the MIPS assessment, the marks are out of 100. The feedback was in terms of percentage, but at a 5% granularity -- if this was the MIPS, you got 80% (because 16% isn't a multiple of 5%).
Submission reference: IN556
sorry i was referring to the assignment one essay marks. Are these marks out of 20 or 100?
They are out of 20. They were 'in the system' as out of 100, and it hasn't caught up with the reality yet!
Submission reference: IN552
Hi,for assessment1,I've got 13 out of 100 in the student portal,but I am not sure about this,or is it 13 out of 20?
It''s out of 20.
Submission reference: IN569
Could you narrow down at all what will be covered in the WebCT test for the final assessment ?
The 3rd assessment will potentially cover everything that's been lectured on the architecture track this term.
Submission reference: IN585
Is the WebCT test for the final assignment going to be on Thursday as it states in the student portal? When will you notify us of the details
Nope. The 3rd assessment is available on WebCT until the end of term (at about 11pm). Because there isn't any marking to be done as such (nor feedback given), it seems sensible to allow submissions until the last minute. Similar will apply for the alternative 2nd assessment.
Submission reference: IN582
I haven't recived a mark for the MIPS assessment yet, does this indicate a problem?
Most likely, yes. Please get in touch with me by email (frmb).
Submission reference: IN590
Hello, will the assessment 2 quiz on webct be on MIPS or on material from the lectures covered in the operating systems lectures? As the sample quizzes are on operating systems not MIPS as i tried one earlier. Thanks
The alternative 2nd assessment quiz (all 3 parts) are on material from the operating-systems lectures (primarily Fred's lectures; the sample quiz is based on Bob's lectures, to give you some idea of the type of questions).
Maintained by Fred Barnes, last modified Thu May 8 12:58:03 2014 |