This lab is to help you set up and get familiar with two tools we will be using for this class: Discord, used for asking direct questions of me and the TAs; and MARS, the MIPS programming environment and simulator you will use to do your assignments for the first half of the course.

I expect you to read things. Do not just skip words looking for diagrams and examples. Reading documentation is one of the most useful skills for programmers to have. Get used to it.


1. Setting up Discord

If you already have a Discord account and you joined my server and identified yourself to the bot, you can skip ahead to the next section. Otherwise, keep reading this section.

I sent an announcement on Canvas that explains how to sign up for Discord. Please click that link, read the whole thing carefully, and follow the directions exactly. If you run into problems at any point, please ask me for help.

When you are successfully identified, you should see several channels in the “Chatamari Damacy” server, like:


2. Using Discord effectively

First, make sure you are using Discord on your computer for this section. Asking programming questions with your phone is like trying to cut wood with a butter knife. Technically possible, but not easy.

Once you’re running Discord on your computer, you can go into a channel (like #cs0447), type a message, and hit enter/return to send it. Standard chat application stuff.

But there are two things you need to learn to do so you can ask questions effectively: how to send code and how to take and send screenshots.


2.1 Sending code

Please read this short section on “formatting code” and pay attention to the image.

Now, in the #cs0447 channel, try sending the MIPS code example on that page. To be clear, you do it like so:

  1. hit the backtick ` key three times to write a triple-backtick ```
  2. write mips immediately after the triple-backtick, with no spaces at all
    • at this point, the word mips should turn green, like this:
    • this is Discord telling you “yes, I recognize the name of that language!”
    • if it didn’t turn green, you probably put a space before mips. Don’t do that!
  3. hit enter/return to go to the next line - just trust me, it’ll work!
  4. copy and paste the MIPS code from that page
  5. hit enter/return to go to the next line
  6. put another triple-backtick ``` to close it off
  7. hit enter/return to send the message.

Done correctly, your message should look something like this, with colors:

Please get this working. Please try as many times as you need to get it working. Please ask the TA (or me) for help in getting this working. Please please please please please


2.2 Sending screenshots

If you are sending something that is not code (e.g. program output, a graphical display, Something Weird MARS Is Doing), the easiest way is to send a screenshot, an image of part of your screen.

Do not use your phone camera to take a picture of your computer screen, ever. Every operating system has the ability to take perfect-quality screenshots built-in. It’s much faster and more convenient than your camera, too.

Windows users

If you are using Windows, follow these directions:

  1. Hit Win+Shift+S on your keyboard, that is, hold down the Windows and Shift keys, and hit S. (S, for Screenshot.)
  2. Click and drag a rectangle around the part of the screen you want to share.
  3. Once you let go, the screenshot is now in your clipboard. That means you can now paste it anywhere you like.
  4. Go to #cs0447 in Discord and paste into the message box at the bottom. (Try using Ctrl+V to paste!)
  5. The image should appear in your message, and you can hit enter to send it.

Mac (Apple) users

If you are using a Mac, follow these directions:

  1. Hit Control+Command+Shift+4. I do not understand how Apple comes up with these shortcuts. I imagine their engineers have nine fingers per hand.
  2. Click and drag a rectangle around the part of the screen you want to share.
  3. Once you let go, the screenshot is now in your clipboard. That means you can now paste it anywhere you like.
  4. Go to #cs0447 in Discord and paste into the message box at the bottom. (Try using Cmd+V to paste!)
  5. The image should appear in your message, and you can hit return to send it.

Linux users

idk lol you know more about it than I do


3. Getting and installing MARS

You must use my modified version of MARS! Not the one from Missouri State! Don’t just google MARS! Cmon!

Go to the Software page and download the version of MARS appropriate for your computer.

Platform-specific instructions follow:

Windows users

  1. Run the .exe file you downloaded.
  2. Allow it to run. (If it whines about it being “unverified” or whatever, click “More” and then “run anyway”)
  3. It will install MARS. That’s all it does.
  4. Then open the Start menu and run it.
    • It might be on the “recently installed” list, or you can type “mars” to find it.

That should be it.

macOS (Apple) users

  1. Run the .dmg file you downloaded.
  2. Drag the MARS icon into the Applications folder.
  3. Eject the .dmg file. (Ask for help if you don’t know how)

Now, you have to tell macOS to let you run the program. You only have to do this the first time you run MARS:

  1. Go into your Applications folder.
  2. Right-click the MARS icon, and click Open.
  3. Click “Open Anyway” or whatever it says.

From now on, you can just run it normally (e.g. pin it to the dock, or Cmd+Space, type mars, hit enter)

Linux Users (including Chromebooks!)

You need to have a modern Java runtime environment installed. I think Java 11 is the oldest version that MARS will work with, but even that’s pretty old by now. Check with java -version.

You can run the jar file from the shell like:

java -jar Mars_2241_0830.jar

Or maybe you can just double-click it? idk


4. Making and saving a program

You’re not writing any code this week, but let’s make sure you can actually save, assemble, and run a program.

When you run MARS, it looks something like this:

a diagram of the mars interface.

If the “Mars Messages” panel at the bottom is really big, just grab the horizontal white bar above it and drag it down until it’s a reasonable size.

Now:

  1. File > New
  2. Copy and paste this code into the file you just made:

     .global main
     main:
         li v0, 10
         syscall
    
  3. At this point, you cannot hit the assemble button. That’s because you haven’t saved.
    • You need to save (Ctrl+S/Cmd+S) the file into your personal files:
      • Windows users: your files are in C:\Users\<your username>. Desktop and Documents are in there.
      • macOS users: your files are in /Users/<your username> Desktop and Documents are in there.
      • Linux users: your files are in /home/<your username> but you knew that.
  4. Now you should be able to hit the assemble button and then the run button.
    • When you hit assemble, it switches to the Execute panel…
    • And when you run, it should print this at the bottom:
     -- program is finished running --
    

Good? Good!


That’s it for this page!

If you’re in recitation right now, stick around and get some practice with the stuff we’ve covered in lecture so far by doing the three exercises for lecture 2. Work on them with a friend! Just don’t look at the answers before you do them all!