gwen (gwenix) wrote,

  • Mood:


So, as a few of you know, I've been stressing mightily over my Assembly class the past week. I've tried sitting down and getting the assignment done, and failed to understand the first thing about what's needed. I've asked for help from multiple sources, but I'm just so clueless, I was lost even with the help.

But! I sing praises and happiness to the God that is my TA! I was not the only one in the class THOROUGHLY confused by everything, and he patiently answered our questions and requests for examples, and everything! I now get it! In fact, I sat down at the Beehive post-class and pretty much wrote up the program in an hour. (Well, minus debugging and etc). Yay!

Also, the TA agrees that the book is pretty much crap, the first assignment is way too much for us to be doing at this stage, and he's been pushing the professor for an extension for us to get this done as well. He rules! Yay my TA!

Here's the code we're supposed to translate into MIPS Assembly:

  int j, k, temp, min;
  int length = 9;
  int list[] = {7, 9, 4, 3, 8, 1, 6, 2, 5};

  printf("Before Sort:\n");
  for (k=0; k<length; ++k)
    printf("%d ", list[k]);
  for (k=0; k<length-1; ++k)
    min = k;
    for(j=k+1; j<length; ++j)
      if (list[j] < list[min] )
        min = j;
      if (min!=k)
        list[min] = list[k];
        list[k] = temp;
  printf("\n\nAfter Sort:\n");
  for(k=0; k<length; ++k)
    printf("%d ", list[k]);

Yes, it's a selection sort. Yes, the professor would love us to do it with a stack treatment. Yes, the TA actually exclaimed, "DO NOT DO THIS AS A STACK! It is the better programming way, but you are not ready for it!" Oh, and btw, 90% of the class doesn't know C. Right on!

Me, I went back to my BASIC days (ah, those were the days), and just set it up with a series of Labels to bounce around at each other. I decided that I'd use $a0 and $a1 to indicate the current placeholders for the array elements I'm looking at, pull in from memory, swap if needed, write back out to memory. Bing bang boom, I think the code (minus the output parts) is about 20 lines long. Plus, I decided to not use pseudo-instructions just for the hell of it so that I'm used to what is or isn't those, so I think that ends up being pretty elegant. Very proud of myself I am. :)

Of course, this is all pre-debugging, so we'll see if I feel so good about it all when I sit down to do that part.

  • Upcoming Spring Concert for RCC!

    Hi folks! This Friday and Saturday (April 29 and 30) I'll be in the Renaissance City Choirs production of "Love of Nature, Nature of Love". I'm…

  • If Schroedinger called in a bug..

    Scenario: Schroedinger has a box with a verified dead cat in it. He hands the box to customer support of a company, who later hands him back that…

  • Pumpkin Pasta recipe

    I actually cooked a good meal the other night. Like, this is miraculous. Further, it was VERY low pointage for Weight Watchers, and incredibly…

  • Post a new comment


    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 1 comment