-
Notifications
You must be signed in to change notification settings - Fork 0
/
ARMGenerator.py
47 lines (31 loc) · 1.11 KB
/
ARMGenerator.py
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
class ARGCodigoGenerador:
def __init__(self):
self.valoresIniciales= ""
def construirGOTO(self, etiqueta):
# hay varios tipos de jumps
retorno = f"j {etiqueta}"
pass
def construirMultiplicacion(self, registros):
return f"\tmul {registros[0]}, {registros[1]}, {registros[2]}\n"
def construirSuma(self, registros):
return f"\tadd {registros[0]}, {registros[1]}, {registros[2]}\n"
def construirSumaV2(self, registros, constante):
return f"\tadd {registros[0]}, {registros[1]}, {constante}\n"
def construirResta(self, registros):
return f"\tsub {registros[0]}, {registros[1]}, {registros[2]}\n"
def construirAnd(self, Rdest, Rsrc1, Rsrc2):
retorno = f"and {Rdest}, {Rsrc1}, {Rsrc2}"
pass
def construirEncabezado(self, nombreHeader):
return(f'''
.section .text
.global {nombreHeader}
{nombreHeader}:
''')
def construirFuncionNueva(self, nombre):
return(f'''
{nombre}:
''')
def alocarEspacioMetodo(self, sizeTotal):
retorno = f"\tsub sp, sp, #{sizeTotal}\n"
return retorno