-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcellular.s
More file actions
117 lines (85 loc) · 2.57 KB
/
Copy pathcellular.s
File metadata and controls
117 lines (85 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
https://powcoder.com
代写代考加微信 powcoder
Assignment Project Exam Help
Add WeChat powcoder
########################################################################
# COMP1521 20T2 --- assignment 1: a cellular automaton renderer
#
# Written by <<YOU>>, July 2020.
# Maximum and minimum values for the 3 parameters.
MIN_WORLD_SIZE = 1
MAX_WORLD_SIZE = 128
MIN_GENERATIONS = -256
MAX_GENERATIONS = 256
MIN_RULE = 0
MAX_RULE = 255
# Characters used to print alive/dead cells.
ALIVE_CHAR = '#'
DEAD_CHAR = '.'
# Maximum number of bytes needs to store all generations of cells.
MAX_CELLS_BYTES = (MAX_GENERATIONS + 1) * MAX_WORLD_SIZE
.data
# `cells' is used to store successive generations. Each byte will be 1
# if the cell is alive in that generation, and 0 otherwise.
cells: .space MAX_CELLS_BYTES
# Some strings you'll need to use:
prompt_world_size: .asciiz "Enter world size: "
error_world_size: .asciiz "Invalid world size\n"
prompt_rule: .asciiz "Enter rule: "
error_rule: .asciiz "Invalid rule\n"
prompt_n_generations: .asciiz "Enter how many generations: "
error_n_generations: .asciiz "Invalid number of generations\n"
.text
#
# REPLACE THIS COMMENT WITH A LIST OF THE REGISTERS USED IN
# `main', AND THE PURPOSES THEY ARE ARE USED FOR
#
# YOU SHOULD ALSO NOTE WHICH REGISTERS DO NOT HAVE THEIR
# ORIGINAL VALUE WHEN `run_generation' FINISHES
#
main:
#
# REPLACE THIS COMMENT WITH YOUR CODE FOR `main'.
#
# replace the syscall below with
#
# li $v0, 0
# jr $ra
#
# if your code for `main' preserves $ra by saving it on the
# stack, and restoring it after calling `print_world' and
# `run_generation'. [ there are style marks for this ]
li $v0, 10
syscall
#
# Given `world_size', `which_generation', and `rule', calculate
# a new generation according to `rule' and store it in `cells'.
#
#
# REPLACE THIS COMMENT WITH A LIST OF THE REGISTERS USED IN
# `run_generation', AND THE PURPOSES THEY ARE ARE USED FOR
#
# YOU SHOULD ALSO NOTE WHICH REGISTERS DO NOT HAVE THEIR
# ORIGINAL VALUE WHEN `run_generation' FINISHES
#
run_generation:
#
# REPLACE THIS COMMENT WITH YOUR CODE FOR `run_generation'.
#
jr $ra
#
# Given `world_size', and `which_generation', print out the
# specified generation.
#
#
# REPLACE THIS COMMENT WITH A LIST OF THE REGISTERS USED IN
# `print_generation', AND THE PURPOSES THEY ARE ARE USED FOR
#
# YOU SHOULD ALSO NOTE WHICH REGISTERS DO NOT HAVE THEIR
# ORIGINAL VALUE WHEN `print_generation' FINISHES
#
print_generation:
#
# REPLACE THIS COMMENT WITH YOUR CODE FOR `print_generation'.
#
jr $ra