Tutorial Week 9
Task 1. Assume you are dealing with a 32 bit microprocessor that accesses memory in words (i.e. 32 bits) at a time, while memory is addressed bytewise. You should store strings in memory in an aligned way. You should use as little memory as possibel without becoming unaligned.
• Sketch the memory of the specified machine, with the string “S” stored starting at an address above or equal to 2012 (decimal).
• Sketch the memory of the specified machine, with the string “S” stored starting at an address above or equal to 2013 (decimal).
• Sketch the memory of the specified machine, with the strings “Sunshine”, “Rain”, “Joy”, and “Pain”, stored starting at an address above or equal to 2012 (decimal).
• Sketch the memory of the specified machine, with the strings “Sunshine”, “Rain”, “Joy”, and “Pain”, stored starting at an address above or equal to 2013 (decimal).
Assume that each character in the strings is ASCII, and uses 1 byte of storage.
Task 2. Download and install the SPIM or the MARS MIPS simulators and familiarise yourself with working one of them. I recommend using MARS.
Task 3. Familiarise yourself with the MIPS processor and assembler language. You’ll find lot’s of information here, although the links to http://www.mips.com are now stale and need to go to http://www.imgtec.com instead.
Task 4. Write the following programs in MIPs assembler language.
• A program that counts the content of register $t1 down to 0 and then terminates.
• A program that counts the content of a memory cell down to 0 and then terminates.
• A program that copies 100 Bytes from one region of memory to another.
• A program that copies N words from the memory region starting at A to the memory region starting at B. Note that the source and target regions may overlap, or incrementing a register may lead to wrapping of the register back to 0. Is that a problem for your program?
• Write a program that computes (2+3)*4 and leaves the result on top of the stack (remember that the stack pointer should always point to the first free memory cell that’s above the top of the stack).
It is fine if you just implement the required functionality. However, if you also want to execute your code, say in MARS/SPIM, you’d have to embed it suitably, e.g. add required MIPS assembler directives.