CSC 252 – Project 3: 1-D Cellular Automata
Mars has a simulated screen that we can use to draw some pretty pictures. In the “Tools” menu, you can
select “Bitmap Display”, which will open a new window. Configure the window according to the
screenshot below and hit the “Connect to MIPS” button.
This will create a “screen” that is 64 pixels wide by 64 pixels high (it takes the display width/height
number and divides it by the unit width/height number – this allows us to magnify the drawing. You
could set it to 1, 1, 64, 64, but it appears pretty small and will be frustrating to see single pixels.)
Now what we need to do is to figure out how to draw to it. One way that computers allow access to
hardware devices like a screen is through a technique called memory mapping. Memory mapping means
that we can see the device as an array, in this case, one whose location starts at the beginning of our
.data segment (that’s what the last dropdown menu in the above screenshot allows you to configure –
leave it as shown). What we want to do then is to make sure this space is reserved by our program and
not used for other data, so the very first declaration in our program should be a .space directive that
reserves for each pixel one word (4 bytes) of memory that will be used to hold the color (more on this in
Write a program that clears the Bitmap Display (sets every pixel to white), prompts the user for what
rule they would like to display, prints that rule in binary, and then draws 64 steps of the CA starting from
an initial line where only the center pixel is black.
You are required to have the following functions written according to the MIPS calling convention:
• A function called setPixel(x, y, color) that places a pixel of color at screen coordinates
• A function called clearScreen() that uses setPixel to set every pixel to white (white is
• A function called makeRuleMap(rule) that stores the ith bit of rule into an array called
rule_map in the data segment
• A function called applyRule() that takes the current line, applies the rule from rule_map,
and produces a new line to draw
• A function called drawLine(y) that draws the line at row y on the screen
• And any additional functions that you find to be useful in your design.
Make sure you have adequate comments, including a header at the top of each function that briefly
describes the function’s purpose, has each argument listed, and, if applicable, what it returns.
You may find other example pictures online but realize that they probably simulated having an infinitely
wide screen, so they will appear different than ours once the row gets to be 64 pixels wide. Our border
will cause the simulation to change what rule applies along the edges.
Feel free to use an assembler directive that we haven’t talked about which allows us to make named
.eqv SIZE 64
Allows us to use the immediate 64 in our code by instead referencing the name SIZE. The assembler
basically does a search and replace on “SIZE” but with knowledge of whitespace and the like to not do
things like replace it in a string literal. Unfortunately, it’s not smart enough to allow us to do math (like
SIZE/2), but it’s a good way to have some named constants in our code.
本网站支持 Alipay WeChatPay PayPal等支付方式
E-mail: email@example.com 微信号:vipnxx