example of translation from stm to machine lang

This commit is contained in:
fsan 2021-10-03 22:30:17 -03:00
parent 6723f51f83
commit deaab50a6d
1 changed files with 19 additions and 1 deletions

20
info
View File

@ -8,4 +8,22 @@ exp -> numero (literal) -> number
exp -> id (idExp) -> id
exp -> exp op exp (operacion) -> opexp
op -> + (suma) -> plus
op -> - (resta) -> minus
op -> - (resta) -> minus
IR:
example:
a = 2 + 2
=>
a = 4
=>
MOV a, 0x0004
a = b + 2
=>
MOV r1, [b]
ADD r1, 0x0002
MOV a, r1
=>
MOV r1, [0xf000]
ADD r1, 0x0002
MOV 0xf001, r1