compiler construction - Convert 3 Address codes in Assembly -


i trying convert 3 address codes in assembly code [code generation].

consider,

enter image description here

the assembly code sequence is:

enter image description here

if order changed t2 t3 t1 t4, then

enter image description here

  1. add done memory operand + register operand sub never done memory operand. similarly, have seen mul never done memory operand. there rule ?

  2. why mov r0,t1 used? isn't better use 1 more register , keep using r0?

  3. bring t1 down, t2-t3-t1-t4 new sequence , save instructions i.e. can use reg keeps value of t1 in next instruction. use register after immediate instruction have store in memory?

typically, operands have involve @ least 1 register cannot, example, subtract t1 t2 directly. therefore, have move op1 register , apply operation op2 - result going register. in case, e-t1 cannot used register (it's on wrong side of operand) whereas t1-e could.

one alternative negate , add t1 used without resorting memory. so:

mov   a, r0 add   b, r0           ; t1 (r0) := a+b mov   c, r1 add   d, r1           ; t2 (r1) := c+d neg   r1 add   e, r1           ; t3 (r1) := e+(-t2) neg   r1 add   r0, r1          ; t4 (r1) := t1+(-t3) 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -