References: CPE380 Assembly Languages

The lecture slides as a PDF provide a good overview of everything. For this material, the textbook is mostly useful as a reference on the MIPS ISA, although it also gives a few examples from other assembly languages.

Generic Assembly Language Stuff

Aside from the discussion in the text (which starts with MIPS and then discusses some other assembly languages for popular ISAs) and the slides posted at this site, the "generic" translation of various high-level language constructs into assmbly language is discussed in detail in the course notes I wrote years ago for the undergraduate compilers course at Purdue. The complete notes are available as .ps and .pdf; only the chapter about "compilation goals" is really relevant. Be warned that the stack instruction set discussed in the old notes does not exactly match what we are using in class.

MIPS Resources

The only assembly language you'll actually have to write code in for this course is MIPS. The programs will all be simple things like this small example program.

SPIM is a MIPS32 simulator (with a built-in assembler) written by James Larus way back in 1990. It has been the standard simulator for MIPS ever since, and is the tool we'll assume for most of our discussion of MIPS assembly language programming. The latest version is QtSpim, which can be compiled to run under Windows, Mac OS X, and Linux from the same freely-available source code. Compiled versions are available from the SPIM sourceforge site, and it is definitely worth installing.

Some years ago, I modified SPIM 6.3 to work using an HTML form interface so that students would not need to install anything to run their assembly language programs. When our CGI server died at the start of Spring 2015, I upgraded it to use SPIM 9.1, and that's what's now available at http://garage.ece.engr.uky.edu:10043/cgi-bin/cgispim.cgi. The documentation for SPIM 6.2 (.pdf and .ps) is still a decent reference for the MIPS instruction set we will be using in this class as well as decribing the use of SPIM. Note that this simple MIPS simulator includes a tiny operating system the interface to which is also described in the documentation.

There are other MIPS simulators around. For example WeMIPS is at a very similar level, but does not support assembler directives like .data. There's also CPUlator, which is pretty slick in its implementation of SPIM MIPS, but has a bit of a learning curve. Some simulators are much more detailed than we need right now... for example, the Verilog MIPS processor being developed through the team projects in this class...

Compilers

In real life, hopefully most of you will never write an entire program in assembly language, but merely will tweak assembly code generated by a compiler or write assembly-language "wrappers" to make special instructions that the compiler doesn't understand still be callable from your HLL programs.

Most compilers have a command-line option to stop at generation of the assembly language code rather than automatically proceeding to assemble and link. The option for most UNIX-derived compilers is -s. This provides a great way to see what various HLL constructs really generate.

I found an online MIPS gcc 5.4 C++ compiler that you can use to try simple sequences. This "Compiler Explorer" actually has a variety of compilers installed so that you can easily see code generated for various assembly languages. The MIPS code output is of good quality (excellent quality if you give it the -O6 compiler option) and fully compliant with the ABI; however, be warned that it will use instructions that are extensions of the basic MIPS ISA we use in this class.

I also created mucky (MIPS uCompiler from KY) and have it set-up with a WWW form interface at http://garage.ece.engr.uky.edu:10043/cgi-bin/mucky.cgi. I've also made available the fairly readable C source code, which uses a simple CGI interface. This compiler will allow you to see what a very dumb compiler might do with code written in a simple C subset. The C subset uses ANSI C notation and is quite small, allowing only char, short, and int variables and single-dimension arrays of them. The output code should work directly as input to spim (described above) and includes C-callable wrappers for print_string(), print_int(), and exit() OS calls. The bad news is that mucky just compiles a poorly-documented C subset and does not comply with the MIPS ABI guidelines (e.g., it doesn't use the standard call interface), so you can't mix mucky-generated code with code generated by other MIPS compilers.


CPE380 Computer Organization and Design.