Difference between revisions of "CSC231 Homework 8 2010"
(Created page with '--~~~~ ---- <center> <font size="+2">Page under construction!</font> <br \>300px </center> __TOC__ <br /> <br /> <br /> <br /> <br /> <tanbox…') |
(→Submission) |
||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
--[[User:Thiebaut|D. Thiebaut]] 13:36, 11 November 2010 (UTC) | --[[User:Thiebaut|D. Thiebaut]] 13:36, 11 November 2010 (UTC) | ||
---- | ---- | ||
− | + | ||
− | |||
− | |||
− | |||
− | |||
− | |||
__TOC__ | __TOC__ | ||
<br /> | <br /> | ||
− | + | <br /> | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | <br /> | ||
<tanbox> | <tanbox> | ||
This homework is due Wednesday evening, 11/17/10, at midnight. You can work on this assignment in pairs. | This homework is due Wednesday evening, 11/17/10, at midnight. You can work on this assignment in pairs. | ||
Line 35: | Line 24: | ||
Read the page on [http://en.wikipedia.org/wiki/Conway's_Game_of_Life Conway's Game of Life] on Wikipedia. Great introduction. | Read the page on [http://en.wikipedia.org/wiki/Conway's_Game_of_Life Conway's Game of Life] on Wikipedia. Great introduction. | ||
− | ;Assignment 2 | + | ;Assignment 3 |
+ | |||
+ | Your assignment is simple, and you have to write a program that you may have already written in one or two different languages before: [Conway's Game of Life]. The challenge this time, is that it must be done in assembly, using functions where parameters are passed through the stack and not via registers, and you have to write it without the '''compare''' instruction that would normally be used for this purpose (I'll show you a way around it). | ||
+ | |||
+ | =Details= | ||
+ | |||
+ | * Your program should be called hw8.asm | ||
+ | * It should maintain the cells in a 1-dimensional array of size 70 | ||
+ | * Each cell can be either dead or alive. Dead cells are printed as spaces (or dots), life cells with a character of your choice. | ||
+ | * You are free to choose the initial population in the array | ||
+ | * The rules are simple: | ||
+ | ** If a cell has 2 live neighbors in a generation, it dies in the next (overpopulation). | ||
+ | ** If a cell has no live neighbors in a generation, it dies in the next (underpopulation). | ||
+ | ** If a cell has only one live neighbor in a generation, it either remains alive in the next, or is born in the next. | ||
+ | * Your program will print each generation one above the next, one line at a time. | ||
+ | * Your program should print at least 20 generations, but no more than 60, so as to limit the size of the printout I'll hand back to you. | ||
+ | * Below is an example generated by the applet on Garret Wilson's [http://www.garretwilson.com/education/institutions/soas/dissertation/lifecellauto1d.html page], where the initial population was of size 6, distributed as follows: ..XXX.XXX....... where dots are dead, and Xs are alive. | ||
+ | |||
+ | <br /> | ||
+ | <br /> | ||
+ | <center> | ||
+ | [[Image:1DGameOfLife.png]] | ||
+ | </center> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | |||
+ | =Requirements= | ||
+ | * Top-Down design | ||
+ | * Use functions for everything. At least one for computing the new generation, one for printing it. | ||
+ | * Functions '''cannot''' pass information through registers. Only via the stack! | ||
+ | |||
+ | =Tricks= | ||
+ | |||
+ | * At some point you will have to compute the number of neighbors for each cell. A simple way to do this is to maintain your array of cells as a collection of integers that are either 0 or 1, 0 for dead, one for alive. Then when you want to compute the number of neighbors of cell Cell[i], you add together Cell[i-1] to Cell[i+1]. You will get 0, 1, or 2. You can create another array containing the rules of the game, so that you know how what the fate of the cell is by looking it up in the array. | ||
+ | |||
+ | fate db 0, 1, 0 | ||
+ | |||
+ | :if the number of neighbors is stored in ebx, for example, then mov al,[fate+ebx] will put the fate of the cell in al. This is the type of trick you can use when you can't compare ebx to 0, 1 or 2. | ||
+ | =Submission= | ||
− | + | submit hw8 hw8.asm | |
− | + | <br /> | |
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | <br /> | ||
+ | [[Category:CSC231]][[Category:Homework]] |
Latest revision as of 19:44, 21 November 2010
--D. Thiebaut 13:36, 11 November 2010 (UTC)
This homework is due Wednesday evening, 11/17/10, at midnight. You can work on this assignment in pairs.
Game of Life in 1D
- Assignment 1
Watch Conway talk about the Game of Life on YouTube (Parts 1 and 2).
- Assignment 2
Read the page on Conway's Game of Life on Wikipedia. Great introduction.
- Assignment 3
Your assignment is simple, and you have to write a program that you may have already written in one or two different languages before: [Conway's Game of Life]. The challenge this time, is that it must be done in assembly, using functions where parameters are passed through the stack and not via registers, and you have to write it without the compare instruction that would normally be used for this purpose (I'll show you a way around it).
Details
- Your program should be called hw8.asm
- It should maintain the cells in a 1-dimensional array of size 70
- Each cell can be either dead or alive. Dead cells are printed as spaces (or dots), life cells with a character of your choice.
- You are free to choose the initial population in the array
- The rules are simple:
- If a cell has 2 live neighbors in a generation, it dies in the next (overpopulation).
- If a cell has no live neighbors in a generation, it dies in the next (underpopulation).
- If a cell has only one live neighbor in a generation, it either remains alive in the next, or is born in the next.
- Your program will print each generation one above the next, one line at a time.
- Your program should print at least 20 generations, but no more than 60, so as to limit the size of the printout I'll hand back to you.
- Below is an example generated by the applet on Garret Wilson's page, where the initial population was of size 6, distributed as follows: ..XXX.XXX....... where dots are dead, and Xs are alive.
Requirements
- Top-Down design
- Use functions for everything. At least one for computing the new generation, one for printing it.
- Functions cannot pass information through registers. Only via the stack!
Tricks
- At some point you will have to compute the number of neighbors for each cell. A simple way to do this is to maintain your array of cells as a collection of integers that are either 0 or 1, 0 for dead, one for alive. Then when you want to compute the number of neighbors of cell Cell[i], you add together Cell[i-1] to Cell[i+1]. You will get 0, 1, or 2. You can create another array containing the rules of the game, so that you know how what the fate of the cell is by looking it up in the array.
fate db 0, 1, 0
- if the number of neighbors is stored in ebx, for example, then mov al,[fate+ebx] will put the fate of the cell in al. This is the type of trick you can use when you can't compare ebx to 0, 1 or 2.
Submission
submit hw8 hw8.asm