OpenCores
URL https://opencores.org/ocsvn/2d_game_console/2d_game_console/trunk

Subversion Repositories 2d_game_console

[/] [2d_game_console/] [trunk/] [test_code_generator_0715.py] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 lucas.vbal
#Author: Lucas Alves
2
#License: Public Domain
3
#Assembly Test Code Generator
4
 
5
#import string
6
import sys
7
 
8
from tkinter import *
9
from tkinter import filedialog
10
from tkinter import messagebox
11
import os
12
import math
13
 
14
results_list = []
15
 
16
color_dict = {'RED':31, 'GREEN':2016 ,'BLUE':-2048, 'YELLOW':2047, 'MAGENTA':-2017, 'CYAN':-32, 'GRAY':-31728, 'BLACK': 0,
17
              'WHITE':-1, 'BROWN':10580, 'PURPLE':-32752, 'ORANGE':1343, 'PINK':-12769, 'GOLD':1727, 'SILVER':-14824, 'OLIVE':1040}
18
 
19
class GUI:
20
 
21
    # Contructor
22
    def __init__(self):
23
        self.root = Tk()
24
        self.root.title("Assembly Test Code Generator")
25
        self.root.resizable(False, False)
26
 
27
        fileLabelFrame = Frame(self.root)
28
        fileLabelFrame.pack(fill=BOTH)
29
 
30
        fileLabel = Label(fileLabelFrame, text="Assembly file:")
31
        fileLabel.pack(side=LEFT, padx=5, pady=0)
32
 
33
        fileFrame = Frame(self.root)
34
        fileFrame.pack(fill=BOTH)
35
 
36
        self.fileEntry = Entry(fileFrame, width=50)
37
        self.fileEntry.pack(side=LEFT, padx=5, pady=10)
38
 
39
        browseButton = Button(fileFrame, text="Save As...", fg="black", command=self.ask_save_file)
40
        browseButton.pack(side=LEFT, padx=5, pady=0)
41
 
42
        self.root.mainloop()
43
 
44
    def ask_save_file(self):
45
        currdir = os.getcwd()
46
        self.filenameSaved = filedialog.asksaveasfilename(parent=self.root, initialdir=currdir, title='Save file',
47
                                                          defaultextension='.asm', filetypes = [("Assembly File","*.asm")])
48
        if len(self.filenameSaved) > 0:
49
            self.fileEntry.delete(0, END)
50
            self.fileEntry.insert(0, self.filenameSaved)
51
            self.execute()
52
 
53
    def quit(self):
54
        self.root.destroy()
55
        sys.exit()
56
 
57
    def execute(self):
58
        self.mif_file = open(self.filenameSaved, 'w')
59
        address = 1032                                          # Memory start address for data storage
60
        values_list = [0, -1, 1, -21846, 21845, 32767, -32768]  # Registers values
61
 
62
 
63
        self.mif_file.write('BEGIN:\n')
64
        self.mif_file.write('\tLIMM R0, 0     ' + '     ' + '// R0 <- 0000000000000000 (=0) \n')
65
        self.mif_file.write('\tLIMM R1, 0     ' + '     ' + '// R1 <- 0000000000000000 (=0) \n')
66
        self.mif_file.write('\tLIMM R2, -1    ' + '     ' + '// R2 <- 1111111111111111 (=-1) \n')
67
        self.mif_file.write('\tLIMM R3, 1     ' + '     ' + '// R3 <- 0000000000000001 (=1) \n')
68
        self.mif_file.write('\tLIMM R4, -21846' + '     ' + '// R4 <- 1010101010101010 (=-21846) \n')
69
        self.mif_file.write('\tLIMM R5, 21845 ' + '     ' + '// R5 <- 0101010101010101 (=21845) \n')
70
        self.mif_file.write('\tLIMM R6, 32767 ' + '     ' + '// R6 <- 0111111111111111 (=32767) \n')
71
        self.mif_file.write('\tLIMM R7, -32768' + '     ' + '// R7 <- 1000000000000000 (=-32768) \n')
72
 
73
        self.mif_file.write('\n')
74
 
75
        # SPRITES
76
        first_row = 33
77
        last_row = 512
78
        first_column = 48
79
        last_column = 687
80
 
81
        for index in range(0, 16):
82
            color_values = list(color_dict.values())
83
            color = color_values[index]
84
 
85
            self.mif_file.write('SPRITE_LEVEL_' + str(index) + ':\n')
86
 
87
            # SPRITE LEVEL
88
            self.mif_file.write('\tLIMM R28, {:<6}'.format(index) )
89
            self.mif_file.write('\t\t\t// R28 <- ')
90
            self.mif_file.write(str(index) + ' (Sprite Level ' + str(index) + ')\n')
91
 
92
            if (index < 8):
93
                row = first_row+20
94
                column = first_column+20 + (index * 20)
95
 
96
                # SPRITE ROW
97
                self.mif_file.write('\tLIMM R1' + str(index) + ', {:<6}'.format(row) )
98
                self.mif_file.write('\t\t\t// R1' + str(index) + ' <- ')
99
                self.mif_file.write(str(row) + ' (Sprite Level ' + str(index) + ' row value = ' + str(row) + ')\n')
100
 
101
                # SPRITE COLUMN
102
                self.mif_file.write('\tLIMM R2' + str(index) + ', {:<6}'.format(column) )
103
                self.mif_file.write('\t\t\t// R2' + str(index) + ' <- ')
104
                self.mif_file.write(str(column) + ' (Sprite Level ' + str(index) + ' column value = ' + str(column) + ')\n')
105
 
106
                # SPRITE POSITION
107
                self.mif_file.write('\tSPRITE_POS R28, R1' + str(index) + ', R2' + str(index))
108
                self.mif_file.write('\t// SPRITE_POS LEVEL, ROW, COLUMN\n')
109
 
110
                self.mif_file.write('\n')
111
 
112
            else:
113
                if (index == 8):
114
                    row = 265
115
                    column = 360
116
 
117
                if (index == 9):
118
                    row = first_row + 1
119
                    column = first_column + 1
120
 
121
                if (index == 10):
122
                    row = first_row + 1
123
                    column = last_column - 16
124
 
125
                if (index == 11):
126
                    row = last_row - 16
127
                    column = first_column + 1
128
 
129
                if (index == 12):
130
                    row = last_row - 16
131
                    column = last_column - 16
132
 
133
                if ( (index >= 13) and (index < 16) ):
134
                    row = first_row + 40
135
                    column = first_column+20 + ((index-13) * 20)
136
 
137
                # SPRITE ROW
138
                self.mif_file.write('\tLIMM R9, ' + '{:<6}'.format(row) )
139
                self.mif_file.write('\t\t\t\t// R9 <- ')
140
                self.mif_file.write(str(row) + ' (Sprite Level ' + str(index) + ' row value = ' + str(row) + ')\n')
141
 
142
                # SPRITE COLUMN
143
                self.mif_file.write('\tLIMM R29, {:<6}'.format(column) )
144
                self.mif_file.write('\t\t\t// R29 <- ')
145
                self.mif_file.write(str(column) + ' (Sprite Level ' + str(index) + ' column value = ' + str(column) + ')\n')
146
 
147
                # SPRITE POSITION
148
                self.mif_file.write('\tSPRITE_POS R28, R9, R29')
149
                self.mif_file.write('\t\t// SPRITE_POS LEVEL, ROW, COLUMN\n')
150
 
151
                self.mif_file.write('\n')
152
 
153
            # SPRITE ID
154
            self.mif_file.write('\tLIMM R29, {:<6}'.format(index) )
155
            self.mif_file.write('\t\t\t// R29 <- ')
156
            self.mif_file.write(str(index) + ' (Sprite ID ' + str(index) + ')\n')
157
 
158
            self.mif_file.write('\tSPRITE_ID R28, R29')
159
            self.mif_file.write('\t\t\t// SPRITE_ID LEVEL, ID\n')
160
 
161
            self.mif_file.write('\n')
162
 
163
            # SPRITE COLOR
164
            self.mif_file.write('\tLIMM R29, {:<6}'.format(color) )
165
            self.mif_file.write('\t\t\t// R29 <- ')
166
            self.mif_file.write(str(color) + ' (Sprite Color ' + str(color) + ')\n')
167
 
168
            self.mif_file.write('\tSPRITE_COLOR R28, R29')
169
            self.mif_file.write('\t\t// SPRITE_COLOR LEVEL, COLOR\n')
170
 
171
            self.mif_file.write('\n')
172
 
173
 
174
        # LOOP START
175
        self.mif_file.write('START:\n')
176
        self.mif_file.write('\tLIMM R0, 0     ' + '     ' + '// R0 <- 0000000000000000 (=0) \n')
177
        self.mif_file.write('\tLIMM R1, 0     ' + '     ' + '// R1 <- 0000000000000000 (=0) \n')
178
        self.mif_file.write('\tLIMM R2, -1    ' + '     ' + '// R2 <- 1111111111111111 (=-1) \n')
179
        self.mif_file.write('\tLIMM R3, 1     ' + '     ' + '// R3 <- 0000000000000001 (=1) \n')
180
        self.mif_file.write('\tLIMM R4, -21846' + '     ' + '// R4 <- 1010101010101010 (=-21846) \n')
181
        self.mif_file.write('\tLIMM R5, 21845 ' + '     ' + '// R5 <- 0101010101010101 (=21845) \n')
182
        self.mif_file.write('\tLIMM R6, 32767 ' + '     ' + '// R6 <- 0111111111111111 (=32767) \n')
183
        self.mif_file.write('\tLIMM R7, -32768' + '     ' + '// R7 <- 1000000000000000 (=-32768) \n')
184
 
185
        self.mif_file.write('\n')
186
 
187
        self.mif_file.write('\t//Enable all interrupts\n')
188
        self.mif_file.write('\tSW R2, 1024 (R0)')
189
        self.mif_file.write('\t// ADDR 1024: <- 1111111111111111 (=-1)\n')
190
 
191
        self.mif_file.write('\n')
192
 
193
        self.mif_file.write('\t//Move Sprite 7\n')
194
        # SPRITE LEVEL 7
195
        self.mif_file.write('\tLIMM R28, {:<6}'.format(7) )
196
        self.mif_file.write('\t\t\t// R28 <- ')
197
        self.mif_file.write(str(7) + ' (Sprite Level ' + str(7) + ')\n')
198
        # INCREMENT ROW POSITION
199
        self.mif_file.write('\tADD R17, R3')
200
        self.mif_file.write('\t\t\t\t\t// R17 + R3 = R17 + 1\n')
201
        # INCREMENT COLUMN POSITION
202
        self.mif_file.write('\tADD R27, R3')
203
        self.mif_file.write('\t\t\t\t\t// R27 + R3 = R27 + 1\n')
204
        # SPRITE POSITION
205
        self.mif_file.write('\tSPRITE_POS R28, R17, R27')
206
        self.mif_file.write('\t// SPRITE_POS LEVEL, ROW, COLUMN\n')
207
 
208
        self.mif_file.write('\n')
209
 
210
        # ADD
211
        for reg_a in range(1, 8):
212
            self.mif_file.write('\nADD_R' + str(reg_a) + ':\n')                                             # Change operation (ADD, SUB, etc)
213
            for reg_b in range(1, 8):
214
                address = address + 1
215
                result = values_list[reg_a-1] + values_list[reg_b-1]                                        # Change sign (+, -, etc)
216
                if ( (result > 32767) or (result < -32768) ):
217
                    results_list.append(-1)
218
                else:
219
                    results_list.append(result)
220
 
221
                self.mif_file.write('\tADD R' + str(reg_a) + ', R' + '{:<7}'.format(reg_b) )                # Change operation (ADD, SUB, etc)
222
                self.mif_file.write('\t// R' + str(reg_a) + ' + R' + str(reg_b) + ' = ' + str(result))      # Change sign (+, -, etc)
223
                if ( (result > 32767) or (result < -32768) ):
224
                    self.mif_file.write(' (R' + str(reg_a) + ' <- -1' + ') !!!!!OVERFLOW!!!!!\n')
225
                else:
226
                    self.mif_file.write(' (R' + str(reg_a) + ' <- ' + str(result) + ') \n')
227
 
228
                self.mif_file.write('\tSW R' + str(reg_a) + ', ' + str(address) + ' (R0)')
229
                if ( (result > 32767) or (result < -32768) ):
230
                    self.mif_file.write('\t// ADDR ' + str(address) + ': <- -1' + '\n')
231
                else:
232
                    self.mif_file.write('\t// ADDR ' + str(address) + ': <- ' + str(result) + '\n')
233
 
234
                self.mif_file.write('\tLIMM R' + str(reg_a) + ', ' + '{:<6}'.format(values_list[reg_a-1]) )
235
                self.mif_file.write('\t\t// R' + str(reg_a) + ' <- ' + str(values_list[reg_a-1]) + '\n')
236
 
237
                if ( (result > 32767) or (result < -32768) ):
238
                    self.mif_file.write('\tBRFL ERROR, 6, 0')
239
                    self.mif_file.write('\t// BRANCH TO ERROR IF RFLAGS[6] = 0\n')
240
                else:
241
                    self.mif_file.write('\tBRFL ERROR, 6, 1')
242
                    self.mif_file.write('\t// BRANCH TO ERROR IF RFLAGS[6] = 1\n')
243
 
244
                self.mif_file.write('\n')
245
 
246
 
247
        # SUB
248
        for reg_a in range(1, 8):
249
            self.mif_file.write('\nSUB_R' + str(reg_a) + ':\n')                                             # Change operation (ADD, SUB, etc)
250
            for reg_b in range(1, 8):
251
                address = address + 1
252
                result = values_list[reg_a-1] - values_list[reg_b-1]                                        # Change sign (+, -, etc)
253
                if ( (result > 32767) or (result < -32768) ):
254
                    results_list.append(-1)
255
                else:
256
                    results_list.append(result)
257
 
258
                self.mif_file.write('\tSUB R' + str(reg_a) + ', R' + '{:<7}'.format(reg_b) )                # Change operation (ADD, SUB, etc)
259
                self.mif_file.write('\t// R' + str(reg_a) + ' - R' + str(reg_b) + ' = ' + str(result))      # Change sign (+, -, etc)
260
                if ( (result > 32767) or (result < -32768) ):
261
                    self.mif_file.write(' (R' + str(reg_a) + ' <- -1' + ') !!!!!OVERFLOW!!!!!\n')
262
                else:
263
                    self.mif_file.write(' (R' + str(reg_a) + ' <- ' + str(result) + ') \n')
264
 
265
                self.mif_file.write('\tSW R' + str(reg_a) + ', ' + str(address) + ' (R0)')
266
                if ( (result > 32767) or (result < -32768) ):
267
                    self.mif_file.write('\t// ADDR ' + str(address) + ': <- -1' + '\n')
268
                else:
269
                    self.mif_file.write('\t// ADDR ' + str(address) + ': <- ' + str(result) + '\n')
270
 
271
                self.mif_file.write('\tLIMM R' + str(reg_a) + ', ' + '{:<6}'.format(values_list[reg_a-1]) )
272
                self.mif_file.write('\t\t// R' + str(reg_a) + ' <- ' + str(values_list[reg_a-1]) + '\n')
273
 
274
                if ( (result > 32767) or (result < -32768) ):
275
                    self.mif_file.write('\tBRFL ERROR, 6, 0')
276
                    self.mif_file.write('\t// BRANCH TO ERROR IF RFLAGS[6] = 0\n')
277
                else:
278
                    self.mif_file.write('\tBRFL ERROR, 6, 1')
279
                    self.mif_file.write('\t// BRANCH TO ERROR IF RFLAGS[6] = 1\n')
280
 
281
                self.mif_file.write('\n')
282
 
283
 
284
        # MUL
285
        for reg_a in range(1, 8):
286
            self.mif_file.write('\nMUL_R' + str(reg_a) + ':\n')                                             # Change operation (ADD, SUB, etc)
287
            for reg_b in range(1, 8):
288
                address = address + 1
289
                result = values_list[reg_a-1] * values_list[reg_b-1]                                        # Change sign (+, -, etc)
290
                if ( (result > 32767) or (result < -32768) ):
291
                    results_list.append(-1)
292
                else:
293
                    results_list.append(result)
294
 
295
                self.mif_file.write('\tMUL R' + str(reg_a) + ', R' + '{:<7}'.format(reg_b) )                # Change operation (ADD, SUB, etc)
296
                self.mif_file.write('\t// R' + str(reg_a) + ' * R' + str(reg_b) + ' = ' + str(result))      # Change sign (+, -, etc)
297
                if ( (result > 32767) or (result < -32768) ):
298
                    self.mif_file.write(' (R' + str(reg_a) + ' <- -1' + ') !!!!!OVERFLOW!!!!!\n')
299
                else:
300
                    self.mif_file.write(' (R' + str(reg_a) + ' <- ' + str(result) + ') \n')
301
 
302
                self.mif_file.write('\tSW R' + str(reg_a) + ', ' + str(address) + ' (R0)')
303
                if ( (result > 32767) or (result < -32768) ):
304
                    self.mif_file.write('\t// ADDR ' + str(address) + ': <- -1' + '\n')
305
                else:
306
                    self.mif_file.write('\t// ADDR ' + str(address) + ': <- ' + str(result) + '\n')
307
 
308
                self.mif_file.write('\tLIMM R' + str(reg_a) + ', ' + '{:<6}'.format(values_list[reg_a-1]) )
309
                self.mif_file.write('\t\t// R' + str(reg_a) + ' <- ' + str(values_list[reg_a-1]) + '\n')
310
 
311
                if ( (result > 32767) or (result < -32768) ):
312
                    self.mif_file.write('\tBRFL ERROR, 6, 0')
313
                    self.mif_file.write('\t// BRANCH TO ERROR IF RFLAGS[6] = 0\n')
314
                else:
315
                    self.mif_file.write('\tBRFL ERROR, 6, 1')
316
                    self.mif_file.write('\t// BRANCH TO ERROR IF RFLAGS[6] = 1\n')
317
 
318
                self.mif_file.write('\n')
319
 
320
 
321
        # DIV
322
        for reg_a in range(1, 8):
323
            self.mif_file.write('\nDIV_R' + str(reg_a) + ':\n')                                             # Change operation (ADD, SUB, etc)
324
            for reg_b in range(1, 8):
325
                address = address + 1
326
 
327
                if (values_list[reg_b-1] != 0):
328
                    result = values_list[reg_a-1] / values_list[reg_b-1]                                    # Change sign (+, -, etc)
329
 
330
                    if (values_list[reg_b-1] > 0):
331
                        result = math.floor(result)
332
                    else:
333
                        result = math.ceil(result)
334
                else:
335
                    result = 9999999999
336
 
337
                if ( (result > 32767) or (result < -32768) ):
338
                    results_list.append(-1)                                                                 # Division by 0 and Overflow, result = -1
339
                else:
340
                    results_list.append(result)
341
 
342
                # DIVIDE
343
                self.mif_file.write('\tDIV R' + str(reg_a) + ', R' + '{:<7}'.format(reg_b) )                # Change operation (ADD, SUB, etc)
344
                self.mif_file.write('\t// ' + str(values_list[reg_a-1]) + ' / ' + str(values_list[reg_b-1]) + ' = ' + str(result))      # Change sign (+, -, etc)
345
 
346
                if (result == 9999999999):
347
                    self.mif_file.write(' (R' + str(reg_a) + ' <- -1' + ') !!!!!DIV BY 0!!!!!\n')
348
                else:
349
                    if ( (result > 32767) or (result < -32768) ):
350
                        self.mif_file.write(' (R' + str(reg_a) + ' <- -1' + ') !!!!!OVERFLOW!!!!!\n')
351
                    else:
352
                        self.mif_file.write(' (R' + str(reg_a) + ' <- ' + str(result) + ') \n')
353
 
354
                # STORE WORD
355
                self.mif_file.write('\tSW R' + str(reg_a) + ', ' + str(address) + ' (R0)')
356
                if ( (result > 32767) or (result < -32768) ):
357
                    self.mif_file.write('\t// ADDR ' + str(address) + ': <- -1' + '\n')
358
                else:
359
                    self.mif_file.write('\t// ADDR ' + str(address) + ': <- ' + str(result) + '\n')
360
 
361
                # LOAD IMMEDIATE
362
                self.mif_file.write('\tLIMM R' + str(reg_a) + ', ' + '{:<6}'.format(values_list[reg_a-1]) )
363
                self.mif_file.write('\t\t// R' + str(reg_a) + ' <- ' + str(values_list[reg_a-1]) + '\n')
364
 
365
                # BRANCH
366
                if (result == 9999999999):
367
                    self.mif_file.write('\tBRFL ERROR, 0, 0')
368
                    self.mif_file.write('\t// BRANCH TO ERROR IF RFLAGS[0] = 0\n')
369
 
370
                    self.mif_file.write('\tBRFL ERROR, 6, 1')
371
                    self.mif_file.write('\t// BRANCH TO ERROR IF RFLAGS[6] = 1\n')
372
                else:
373
                    if ( (result > 32767) or (result < -32768) ):
374
                        self.mif_file.write('\tBRFL ERROR, 0, 1')
375
                        self.mif_file.write('\t// BRANCH TO ERROR IF RFLAGS[0] = 1\n')
376
 
377
                        self.mif_file.write('\tBRFL ERROR, 6, 0')
378
                        self.mif_file.write('\t// BRANCH TO ERROR IF RFLAGS[6] = 0\n')
379
                    else:
380
                        self.mif_file.write('\tBRFL ERROR, 0, 1')
381
                        self.mif_file.write('\t// BRANCH TO ERROR IF RFLAGS[0] = 1\n')
382
 
383
                        self.mif_file.write('\tBRFL ERROR, 6, 1')
384
                        self.mif_file.write('\t// BRANCH TO ERROR IF RFLAGS[6] = 1\n')
385
 
386
                self.mif_file.write('\n')
387
 
388
 
389
        # AND
390
        for reg_a in range(1, 8):
391
            self.mif_file.write('\nAND_R' + str(reg_a) + ':\n')                                                     # Change operation (ADD, SUB, etc)
392
            for reg_b in range(1, 8):
393
                address = address + 1
394
                result = values_list[reg_a-1] & values_list[reg_b-1]                                                # Change sign (+, -, etc)
395
                results_list.append(result)
396
 
397
                self.mif_file.write('\t// ' + '{0:016b}'.format(values_list[reg_a-1] & 0b1111111111111111)
398
                                    + ' <- R' + str(reg_a) + ' = ' + str(values_list[reg_a-1]) + '\n' )
399
                self.mif_file.write('\t// ' + '{0:016b}'.format(values_list[reg_b-1] & 0b1111111111111111)
400
                                    + ' <- R' + str(reg_b) + ' = ' + str(values_list[reg_b-1]) + '\n' )
401
                self.mif_file.write('\t// ' + '{0:016b}'.format(result & 0b1111111111111111)
402
                                    + ' <- R' + str(reg_a) + ' & R' + str(reg_b) + ' = ' + str(result) + '\n' )     # Change sign (+, -, etc)
403
 
404
                self.mif_file.write('\tAND R' + str(reg_a) + ', R' + '{:<7}'.format(reg_b) )                        # Change operation (ADD, SUB, etc)
405
                self.mif_file.write('\t// (R' + str(reg_a) + ' <- ' + str(result) + ') \n')
406
 
407
                self.mif_file.write('\tSW R' + str(reg_a) + ', ' + str(address) + ' (R0)')
408
                self.mif_file.write('\t// ADDR ' + str(address) + ': <- ' + str(result) + '\n')
409
 
410
                self.mif_file.write('\tLIMM R' + str(reg_a) + ', ' + '{:<6}'.format(values_list[reg_a-1]) )
411
                self.mif_file.write('\t\t// R' + str(reg_a) + ' <- ' + str(values_list[reg_a-1]) + '\n' )
412
 
413
                self.mif_file.write('\n')
414
 
415
 
416
        # OR
417
        for reg_a in range(1, 8):
418
            self.mif_file.write('\nOR_R' + str(reg_a) + ':\n')                                                      # Change operation (ADD, SUB, etc)
419
            for reg_b in range(1, 8):
420
                address = address + 1
421
                result = values_list[reg_a-1] | values_list[reg_b-1]                                                # Change sign (+, -, etc)
422
                results_list.append(result)
423
 
424
                self.mif_file.write('\t// ' + '{0:016b}'.format(values_list[reg_a-1] & 0b1111111111111111)
425
                                    + ' <- R' + str(reg_a) + ' = ' + str(values_list[reg_a-1]) + '\n' )
426
                self.mif_file.write('\t// ' + '{0:016b}'.format(values_list[reg_b-1] & 0b1111111111111111)
427
                                    + ' <- R' + str(reg_b) + ' = ' + str(values_list[reg_b-1]) + '\n' )
428
                self.mif_file.write('\t// ' + '{0:016b}'.format(result & 0b1111111111111111)
429
                                    + ' <- R' + str(reg_a) + ' | R' + str(reg_b) + ' = ' + str(result) + '\n' )     # Change sign (+, -, etc)
430
 
431
                self.mif_file.write('\tOR R' + str(reg_a) + ', R' + '{:<8}'.format(reg_b) )                         # Change operation (ADD, SUB, etc)
432
                self.mif_file.write('\t// (R' + str(reg_a) + ' <- ' + str(result) + ') \n')
433
 
434
                self.mif_file.write('\tSW R' + str(reg_a) + ', ' + str(address) + ' (R0)')
435
                self.mif_file.write('\t// ADDR ' + str(address) + ': <- ' + str(result) + '\n')
436
 
437
                self.mif_file.write('\tLIMM R' + str(reg_a) + ', ' + '{:<6}'.format(values_list[reg_a-1]) )
438
                self.mif_file.write('\t\t// R' + str(reg_a) + ' <- ' + str(values_list[reg_a-1]) + '\n' )
439
 
440
                self.mif_file.write('\n')
441
 
442
 
443
        # NOT
444
        for reg_a in range(1, 8):
445
            self.mif_file.write('\nNOT_R' + str(reg_a) + ':\n')                                                     # Change operation (ADD, SUB, etc)
446
 
447
            address = address + 1
448
            result = ~ values_list[reg_a-1]                                                                         # Change sign (+, -, etc)
449
            results_list.append(result)
450
 
451
            self.mif_file.write('\t// ' + '{0:016b}'.format(values_list[reg_a-1] & 0b1111111111111111)
452
                                + ' <- R' + str(reg_a) + ' = ' + str(values_list[reg_a-1]) + '\n' )
453
            self.mif_file.write('\t// ' + '{0:016b}'.format(result & 0b1111111111111111)
454
                                + ' <- ~R' + str(reg_a) + ' = ' + str(result) + '\n' )                              # Change sign (+, -, etc)
455
 
456
            self.mif_file.write('\tNOT R' + '{:<11}'.format(reg_a) )                                                # Change operation (ADD, SUB, etc)
457
            self.mif_file.write('\t// (R' + str(reg_a) + ' <- ' + str(result) + ') \n')
458
 
459
            self.mif_file.write('\tSW R' + str(reg_a) + ', ' + str(address) + ' (R0)')
460
            self.mif_file.write('\t// ADDR ' + str(address) + ': <- ' + str(result) + '\n')
461
 
462
            self.mif_file.write('\tLIMM R' + str(reg_a) + ', ' + '{:<6}'.format(values_list[reg_a-1]) )
463
            self.mif_file.write('\t\t// R' + str(reg_a) + ' <- ' + str(values_list[reg_a-1]) + '\n' )
464
 
465
            self.mif_file.write('\n')
466
 
467
 
468
        # CMP
469
        for index, results_list_value in enumerate(results_list):
470
            address = 1033+index
471
            self.mif_file.write('\nCMP_' + str(address) + ':\n')                                                    # Change operation (ADD, SUB, etc)
472
 
473
            result = results_list_value                                                                             # Change sign (+, -, etc)
474
 
475
            self.mif_file.write('\tLW R31, ' + str(address) + ' (R0)')
476
            self.mif_file.write('\t// R31 <- ' + str(result) + ' (ADDR: ' + str(address) + ')' + '\n')
477
 
478
            # R31 = R30 = RESULT
479
            self.mif_file.write('\n\tLIMM R30, ' + '{:<6}'.format(result) )
480
            self.mif_file.write('\t// R30 <- ' + str(result) + '\n' )
481
 
482
            self.mif_file.write('\tCMP R30, R31\n')                                                             # Change operation (ADD, SUB, etc)
483
 
484
            self.mif_file.write('\tBRFL ERROR, 3, 1')
485
            self.mif_file.write('\t// BRANCH TO ERROR IF RFLAGS[3] = 1 (BELOW=1)\n')      #BELOW
486
 
487
            self.mif_file.write('\tBRFL ERROR, 4, 0')
488
            self.mif_file.write('\t// BRANCH TO ERROR IF RFLAGS[4] = 0 (EQUAL=0)\n')      #EQUAL
489
 
490
            self.mif_file.write('\tBRFL ERROR, 5, 1')
491
            self.mif_file.write('\t// BRANCH TO ERROR IF RFLAGS[5] = 1 (ABOVE=1)\n')      #ABOVE
492
 
493
            # R31 > R30 = RESULT-1
494
            if (result > -32768):
495
                self.mif_file.write('\n\tLIMM R30, ' + '{:<6}'.format(result-1) )
496
                self.mif_file.write('\t// R30 <- ' + str(result-1) + '\n' )
497
 
498
                self.mif_file.write('\tCMP R30, R31\n')                                                             # Change operation (ADD, SUB, etc)
499
 
500
                self.mif_file.write('\tBRFL ERROR, 3, 0')
501
                self.mif_file.write('\t// BRANCH TO ERROR IF RFLAGS[3] = 0 (BELOW=0)\n')      #BELOW
502
 
503
                self.mif_file.write('\tBRFL ERROR, 4, 1')
504
                self.mif_file.write('\t// BRANCH TO ERROR IF RFLAGS[4] = 1 (EQUAL=1)\n')      #EQUAL
505
 
506
                self.mif_file.write('\tBRFL ERROR, 5, 1')
507
                self.mif_file.write('\t// BRANCH TO ERROR IF RFLAGS[5] = 1 (ABOVE=1)\n')      #ABOVE
508
 
509
            # R31 < R30 = RESULT+1
510
            if (result < 32767):
511
                self.mif_file.write('\n\tLIMM R30, ' + '{:<6}'.format(result+1) )
512
                self.mif_file.write('\t// R30 <- ' + str(result+1) + '\n' )
513
 
514
                self.mif_file.write('\tCMP R30, R31\n')                                                             # Change operation (ADD, SUB, etc)
515
 
516
                self.mif_file.write('\tBRFL ERROR, 3, 1')
517
                self.mif_file.write('\t// BRANCH TO ERROR IF RFLAGS[3] = 1 (BELOW=1)\n')      #BELOW
518
 
519
                self.mif_file.write('\tBRFL ERROR, 4, 1')
520
                self.mif_file.write('\t// BRANCH TO ERROR IF RFLAGS[4] = 1 (EQUAL=1)\n')      #EQUAL
521
 
522
                self.mif_file.write('\tBRFL ERROR, 5, 0')
523
                self.mif_file.write('\t// BRANCH TO ERROR IF RFLAGS[5] = 0 (ABOVE=0)\n')      #ABOVE
524
 
525
 
526
            self.mif_file.write('\n')
527
 
528
 
529
        self.mif_file.write('SUCCESS:\n')
530
        self.mif_file.write('\tJMP START\n\n')
531
 
532
 
533
        self.mif_file.write('ERROR:\n')
534
        self.mif_file.write('\tJMP ERROR\n\n')
535
 
536
 
537
        # Interruption Service Routine 0
538
        self.mif_file.write('.ISR0:\n')
539
 
540
        # Load buttons values
541
        self.mif_file.write('\tLW R8, 1025 (R0)')
542
        self.mif_file.write('\t\t// R8 <- BUTTONS\n\n')
543
 
544
        # Buttons values
545
        UP = 1
546
        DOWN = 2
547
        LEFT = 4
548
        RIGHT = 8
549
        B = 16
550
        C = 32
551
        A = 64
552
        START = 128
553
        Z = 256
554
        Y = 512
555
        X = 1024
556
        MODE = 2048
557
 
558
        # Image limits
559
        start_row = 33
560
        end_row = 512
561
        start_col = 48
562
        end_col = 687
563
 
564
        check_buttons_list = [(UP+A),       (DOWN+A),       (LEFT+A),       (RIGHT+A),
565
                              (UP+B),       (DOWN+B),       (LEFT+B),       (RIGHT+B),
566
                              (UP+C),       (DOWN+C),       (LEFT+C),       (RIGHT+C),
567
                              (UP+X),       (DOWN+X),       (LEFT+X),       (RIGHT+X),
568
                              (UP+Y),       (DOWN+Y),       (LEFT+Y),       (RIGHT+Y),
569
                              (UP+Z),       (DOWN+Z),       (LEFT+Z),       (RIGHT+Z),
570
                              (UP+START),   (DOWN+START),   (LEFT+START),   (RIGHT+START),
571
                              (UP+MODE),    (DOWN+MODE),    (LEFT+MODE),    (RIGHT+MODE)]
572
 
573
        action_labels_list = ['UP_A',       'DOWN_A',       'LEFT_A',       'RIGHT_A',
574
                              'UP_B',       'DOWN_B',       'LEFT_B',       'RIGHT_B',
575
                              'UP_C',       'DOWN_C',       'LEFT_C',       'RIGHT_C',
576
                              'UP_X',       'DOWN_X',       'LEFT_X',       'RIGHT_X',
577
                              'UP_Y',       'DOWN_Y',       'LEFT_Y',       'RIGHT_Y',
578
                              'UP_Z',       'DOWN_Z',       'LEFT_Z',       'RIGHT_Z',
579
                              'UP_START',   'DOWN_START',   'LEFT_START',   'RIGHT_START',
580
                              'UP_MODE',    'DOWN_MODE',    'LEFT_MODE',    'RIGHT_MODE']
581
 
582
        return_labels_list = ['RETURN_UP_A',        'RETURN_DOWN_A',        'RETURN_LEFT_A',        'RETURN_RIGHT_A',
583
                              'RETURN_UP_B',        'RETURN_DOWN_B',        'RETURN_LEFT_B',        'RETURN_RIGHT_B',
584
                              'RETURN_UP_C',        'RETURN_DOWN_C',        'RETURN_LEFT_C',        'RETURN_RIGHT_C',
585
                              'RETURN_UP_X',        'RETURN_DOWN_X',        'RETURN_LEFT_X',        'RETURN_RIGHT_X',
586
                              'RETURN_UP_Y',        'RETURN_DOWN_Y',        'RETURN_LEFT_Y',        'RETURN_RIGHT_Y',
587
                              'RETURN_UP_Z',        'RETURN_DOWN_Z',        'RETURN_LEFT_Z',        'RETURN_RIGHT_Z',
588
                              'RETURN_UP_START',    'RETURN_DOWN_START',    'RETURN_LEFT_START',    'RETURN_RIGHT_START',
589
                              'RETURN_UP_MODE',     'RETURN_DOWN_MODE',     'RETURN_LEFT_MODE',     'RETURN_RIGHT_MODE']
590
 
591
 
592
        # Check buttons and branch
593
        for index, buttons_value in enumerate(check_buttons_list):
594
 
595
            self.mif_file.write('\t// CHECK ' + action_labels_list[index] + '\n')
596
 
597
            self.mif_file.write('\tLIMM R18, ' + '{:<6}'.format(buttons_value) )
598
            self.mif_file.write('\t\t// R18 <- ')
599
            self.mif_file.write('{0:016b}'.format(buttons_value & 0b1111111111111111) + ' (Value for ' + action_labels_list[index] + ')\n')
600
 
601
            self.mif_file.write('\tLIMM R19, ' + '{:<6}'.format(buttons_value) )
602
            self.mif_file.write('\t\t// R19 <- ')
603
            self.mif_file.write('{0:016b}'.format(buttons_value & 0b1111111111111111) + ' (Value for ' + action_labels_list[index] + ')\n')
604
 
605
            self.mif_file.write('\tAND R18, R8')
606
            self.mif_file.write('\t\t\t\t// Check if ' + action_labels_list[index] + ' are pressed\n')
607
 
608
            self.mif_file.write('\tCMP R18, R19\n')
609
 
610
            self.mif_file.write('\tBRFL ' + '{:>10}'.format(action_labels_list[index]) + ', 4, 1')
611
            self.mif_file.write('\t// Branch to ' + action_labels_list[index] + ' if RFLAGS[4] = 1 (EQUAL=1)\n')
612
 
613
            self.mif_file.write(return_labels_list[index] + ':\n')
614
            self.mif_file.write('\n')
615
 
616
        self.mif_file.write('\tIRET\n\n')
617
 
618
        # Take actions and jump back
619
 
620
        # Actions for UP button
621
        for index in range(0, 8):
622
            self.mif_file.write('\t// ACTIONS FOR ' + action_labels_list[index*4] + ' BUTTONS PRESSED\n')
623
            self.mif_file.write(action_labels_list[index*4] + ':\n')
624
 
625
            self.mif_file.write('\tLIMM R9, ' + '{:<6}'.format(start_row-15) )
626
            self.mif_file.write('\t\t\t\t// R9 <- ')
627
            self.mif_file.write(str(start_row-15) + ' (Start row value - 15 = ' + str(start_row) + ' - 15)\n')
628
 
629
            self.mif_file.write('\tCMP R1' + str(index) + ', R9')
630
            self.mif_file.write('\t\t\t\t\t// R1' + str(index) + ' (Sprite Level ' + str(index) + ' Row register)\n')
631
 
632
            self.mif_file.write('\tBRFL ' + '{:>10}_RST'.format(action_labels_list[index*4]) + ', 4, 1')
633
            self.mif_file.write('\t// Branch to ' + action_labels_list[index*4] + '_RST if RFLAGS[4] = 1 (EQUAL=1)\n')
634
 
635
            self.mif_file.write('\tBRFL ' + '{:>10}_RST'.format(action_labels_list[index*4]) + ', 3, 1')
636
            self.mif_file.write('\t// Branch to ' + action_labels_list[index*4] + '_RST if RFLAGS[3] = 1 (BELOW=1)\n')
637
 
638
            self.mif_file.write('\n')
639
 
640
            self.mif_file.write('\tLIMM R9, ' + '{:<6}'.format(1) )
641
            self.mif_file.write('\t\t\t\t// R9 <- 1\n')
642
 
643
            self.mif_file.write('\tSUB R1' + str(index) + ', R' + '{:<7}'.format(9) )
644
            self.mif_file.write('\t\t\t// R1' + str(index) + ' <- R1' + str(index) + ' - R9 (Decrements row)\n' )
645
 
646
            self.mif_file.write('\tLIMM R9, ' + '{:<6}'.format(index) )
647
            self.mif_file.write('\t\t\t\t// R9 <- ' + str(index) + ' (SPRITE_LEVEL = ' + str(index) + ')\n')
648
 
649
            self.mif_file.write('\tSPRITE_POS R9, R1' + str(index) + ', R2' + str(index))
650
            self.mif_file.write('\t\t// SPRITE_POS LEVEL, ROW, COLUMN\n')
651
 
652
            self.mif_file.write('\tJMP ' + return_labels_list[index*4] + '\n')
653
 
654
            self.mif_file.write('\n')
655
 
656
            self.mif_file.write(action_labels_list[index*4] + '_RST:\n')
657
 
658
            self.mif_file.write('\tLIMM R1' + str(index) + ', {:<6}'.format(end_row) )
659
            self.mif_file.write('\t\t\t// R1' + str(index) + ' <- ')
660
            self.mif_file.write(str(end_row) + ' (End row value = ' + str(end_row) + ')\n')
661
 
662
            self.mif_file.write('\tLIMM R9, ' + '{:<6}'.format(index) )
663
            self.mif_file.write('\t\t\t\t// R9 <- ' + str(index) + ' (SPRITE_LEVEL = ' + str(index) + ')\n')
664
 
665
            self.mif_file.write('\tSPRITE_POS R9, R1' + str(index) + ', R2' + str(index))
666
            self.mif_file.write('\t\t// SPRITE_POS LEVEL, ROW, COLUMN\n')
667
 
668
            self.mif_file.write('\tJMP ' + return_labels_list[index*4] + '\n')
669
            self.mif_file.write('\n\n\n')
670
 
671
 
672
        # Actions for DOWN button
673
        for index in range(0, 8):
674
            self.mif_file.write('\t// ACTIONS FOR ' + action_labels_list[(index*4)+1] + ' BUTTONS PRESSED\n')
675
            self.mif_file.write(action_labels_list[(index*4)+1] + ':\n')
676
 
677
            self.mif_file.write('\tLIMM R9, ' + '{:<6}'.format(end_row) )
678
            self.mif_file.write('\t\t\t\t// R9 <- ')
679
            self.mif_file.write(str(end_row) + ' (End row value = ' + str(end_row) + ')\n')
680
 
681
            self.mif_file.write('\tCMP R1' + str(index) + ', R9')
682
            self.mif_file.write('\t\t\t\t\t// R1' + str(index) + ' (Sprite Level ' + str(index) + ' Row register)\n')
683
 
684
            self.mif_file.write('\tBRFL ' + '{:>10}_RST'.format(action_labels_list[(index*4)+1]) + ', 4, 1')
685
            self.mif_file.write('\t// Branch to ' + action_labels_list[(index*4)+1] + '_RST if RFLAGS[4] = 1 (EQUAL=1)\n')
686
 
687
            self.mif_file.write('\tBRFL ' + '{:>10}_RST'.format(action_labels_list[(index*4)+1]) + ', 5, 1')
688
            self.mif_file.write('\t// Branch to ' + action_labels_list[(index*4)+1] + '_RST if RFLAGS[5] = 1 (ABOVE=1)\n')
689
 
690
            self.mif_file.write('\n')
691
 
692
            self.mif_file.write('\tLIMM R9, ' + '{:<6}'.format(1) )
693
            self.mif_file.write('\t\t\t\t// R9 <- 1\n')
694
 
695
            self.mif_file.write('\tADD R1' + str(index) + ', R' + '{:<7}'.format(9) )
696
            self.mif_file.write('\t\t\t// R1' + str(index) + ' <- R1' + str(index) + ' + R9 (Increments row)\n' )
697
 
698
            self.mif_file.write('\tLIMM R9, ' + '{:<6}'.format(index) )
699
            self.mif_file.write('\t\t\t\t// R9 <- ' + str(index) + ' (SPRITE_LEVEL = ' + str(index) + ')\n')
700
 
701
            self.mif_file.write('\tSPRITE_POS R9, R1' + str(index) + ', R2' + str(index))
702
            self.mif_file.write('\t\t// SPRITE_POS LEVEL, ROW, COLUMN\n')
703
 
704
            self.mif_file.write('\tJMP ' + return_labels_list[(index*4)+1] + '\n')
705
 
706
            self.mif_file.write('\n')
707
 
708
            self.mif_file.write(action_labels_list[(index*4)+1] + '_RST:\n')
709
 
710
            self.mif_file.write('\tLIMM R1' + str(index) + ', {:<6}'.format(start_row-15) )
711
            self.mif_file.write('\t\t\t// R1' + str(index) + ' <- ')
712
            self.mif_file.write(str(start_row-15) + ' (Start row value - 15 = ' + str(start_row) + ' - 15)\n')
713
 
714
            self.mif_file.write('\tLIMM R9, ' + '{:<6}'.format(index) )
715
            self.mif_file.write('\t\t\t\t// R9 <- ' + str(index) + ' (SPRITE_LEVEL = ' + str(index) + ')\n')
716
 
717
            self.mif_file.write('\tSPRITE_POS R9, R1' + str(index) + ', R2' + str(index))
718
            self.mif_file.write('\t\t// SPRITE_POS LEVEL, ROW, COLUMN\n')
719
 
720
            self.mif_file.write('\tJMP ' + return_labels_list[(index*4)+1] + '\n')
721
            self.mif_file.write('\n\n\n')
722
 
723
 
724
        # Actions for LEFT button
725
        for index in range(0, 8):
726
            self.mif_file.write('\t// ACTIONS FOR ' + action_labels_list[(index*4)+2] + ' BUTTONS PRESSED\n')
727
            self.mif_file.write(action_labels_list[(index*4)+2] + ':\n')
728
 
729
            self.mif_file.write('\tLIMM R9, ' + '{:<6}'.format(start_col-15) )
730
            self.mif_file.write('\t\t\t\t// R9 <- ')
731
            self.mif_file.write(str(start_col-15) + ' (Start column value - 15 = ' + str(start_col) + ' - 15)\n')
732
 
733
            self.mif_file.write('\tCMP R2' + str(index) + ', R9')
734
            self.mif_file.write('\t\t\t\t\t// R2' + str(index) + ' (Sprite Level ' + str(index) + ' Column register)\n')
735
 
736
            self.mif_file.write('\tBRFL ' + '{:>10}_RST'.format(action_labels_list[(index*4)+2]) + ', 4, 1')
737
            self.mif_file.write('\t// Branch to ' + action_labels_list[(index*4)+2] + '_RST if RFLAGS[4] = 1 (EQUAL=1)\n')
738
 
739
            self.mif_file.write('\tBRFL ' + '{:>10}_RST'.format(action_labels_list[(index*4)+2]) + ', 3, 1')
740
            self.mif_file.write('\t// Branch to ' + action_labels_list[(index*4)+2] + '_RST if RFLAGS[3] = 1 (BELOW=1)\n')
741
 
742
            self.mif_file.write('\n')
743
 
744
            self.mif_file.write('\tLIMM R9, ' + '{:<6}'.format(1) )
745
            self.mif_file.write('\t\t\t\t// R9 <- 1\n')
746
 
747
            self.mif_file.write('\tSUB R2' + str(index) + ', R' + '{:<7}'.format(9) )
748
            self.mif_file.write('\t\t\t// R2' + str(index) + ' <- R2' + str(index) + ' - R9 (Decrements column)\n' )
749
 
750
            self.mif_file.write('\tLIMM R9, ' + '{:<6}'.format(index) )
751
            self.mif_file.write('\t\t\t\t// R9 <- ' + str(index) + ' (SPRITE_LEVEL = ' + str(index) + ')\n')
752
 
753
            self.mif_file.write('\tSPRITE_POS R9, R1' + str(index) + ', R2' + str(index))
754
            self.mif_file.write('\t\t// SPRITE_POS LEVEL, ROW, COLUMN\n')
755
 
756
            self.mif_file.write('\tJMP ' + return_labels_list[(index*4)+2] + '\n')
757
 
758
            self.mif_file.write('\n')
759
 
760
            self.mif_file.write(action_labels_list[(index*4)+2] + '_RST:\n')
761
 
762
            self.mif_file.write('\tLIMM R2' + str(index) + ', {:<6}'.format(end_col) )
763
            self.mif_file.write('\t\t\t// R2' + str(index) + ' <- ')
764
 
765
            self.mif_file.write(str(end_col) + ' (End column value = ' + str(end_col) + ')\n')
766
 
767
 
768
            self.mif_file.write('\tLIMM R9, ' + '{:<6}'.format(index) )
769
            self.mif_file.write('\t\t\t\t// R9 <- ' + str(index) + ' (SPRITE_LEVEL = ' + str(index) + ')\n')
770
 
771
            self.mif_file.write('\tSPRITE_POS R9, R1' + str(index) + ', R2' + str(index))
772
            self.mif_file.write('\t\t// SPRITE_POS LEVEL, ROW, COLUMN\n')
773
 
774
            self.mif_file.write('\tJMP ' + return_labels_list[(index*4)+2] + '\n')
775
            self.mif_file.write('\n\n\n')
776
 
777
 
778
        # Actions for RIGHT button
779
        for index in range(0, 8):
780
            self.mif_file.write('\t// ACTIONS FOR ' + action_labels_list[(index*4)+3] + ' BUTTONS PRESSED\n')
781
            self.mif_file.write(action_labels_list[(index*4)+3] + ':\n')
782
 
783
            self.mif_file.write('\tLIMM R9, ' + '{:<6}'.format(end_col) )
784
            self.mif_file.write('\t\t\t\t// R9 <- ')
785
            self.mif_file.write(str(end_col) + ' (End column value = ' + str(end_col) + ')\n')
786
 
787
            self.mif_file.write('\tCMP R2' + str(index) + ', R9')
788
            self.mif_file.write('\t\t\t\t\t// R2' + str(index) + ' (Sprite Level ' + str(index) + ' Column register)\n')
789
 
790
            self.mif_file.write('\tBRFL ' + '{:>10}_RST'.format(action_labels_list[(index*4)+3]) + ', 4, 1')
791
            self.mif_file.write('\t// Branch to ' + action_labels_list[(index*4)+3] + '_RST if RFLAGS[4] = 1 (EQUAL=1)\n')
792
 
793
            self.mif_file.write('\tBRFL ' + '{:>10}_RST'.format(action_labels_list[(index*4)+3]) + ', 5, 1')
794
            self.mif_file.write('\t// Branch to ' + action_labels_list[(index*4)+3] + '_RST if RFLAGS[5] = 1 (ABOVE=1)\n')
795
 
796
            self.mif_file.write('\n')
797
 
798
            self.mif_file.write('\tLIMM R9, ' + '{:<6}'.format(1) )
799
            self.mif_file.write('\t\t\t\t// R9 <- 1\n')
800
 
801
            self.mif_file.write('\tADD R2' + str(index) + ', R' + '{:<7}'.format(9) )
802
            self.mif_file.write('\t\t\t// R2' + str(index) + ' <- R2' + str(index) + ' + R9 (Increments column)\n' )
803
 
804
            self.mif_file.write('\tLIMM R9, ' + '{:<6}'.format(index) )
805
            self.mif_file.write('\t\t\t\t// R9 <- ' + str(index) + ' (SPRITE_LEVEL = ' + str(index) + ')\n')
806
 
807
            self.mif_file.write('\tSPRITE_POS R9, R1' + str(index) + ', R2' + str(index))
808
            self.mif_file.write('\t\t// SPRITE_POS LEVEL, ROW, COLUMN\n')
809
 
810
            self.mif_file.write('\tJMP ' + return_labels_list[(index*4)+3] + '\n')
811
 
812
            self.mif_file.write('\n')
813
 
814
            self.mif_file.write(action_labels_list[(index*4)+3] + '_RST:\n')
815
 
816
            self.mif_file.write('\tLIMM R2' + str(index) + ', {:<6}'.format(start_col-15) )
817
            self.mif_file.write('\t\t\t// R2' + str(index) + ' <- ')
818
            self.mif_file.write(str(start_col-15) + ' (Start column value - 15 = ' + str(start_col) + ' - 15)\n')
819
 
820
 
821
            self.mif_file.write('\tLIMM R9, ' + '{:<6}'.format(index) )
822
            self.mif_file.write('\t\t\t\t// R9 <- ' + str(index) + ' (SPRITE_LEVEL = ' + str(index) + ')\n')
823
 
824
            self.mif_file.write('\tSPRITE_POS R9, R1' + str(index) + ', R2' + str(index))
825
            self.mif_file.write('\t\t// SPRITE_POS LEVEL, ROW, COLUMN\n')
826
 
827
            self.mif_file.write('\tJMP ' + return_labels_list[(index*4)+3] + '\n')
828
            self.mif_file.write('\n\n\n')
829
 
830
 
831
        self.mif_file.close()
832
 
833
        messagebox.showinfo(parent=self.root, title='Info', message='Done!')
834
 
835
        self.quit()
836
 
837
 
838
 
839
if __name__ == '__main__':
840
 
841
    gui = GUI()
842
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.