Contents    Page-10    Prev    Next    Page+10    Index   

Code Generation

A starter program codgen.c is furnished. A very simple program, triv.pas, can be compiled by codgen.c:


program graph1(output);
var i:integer;
begin   i := 3   end.

The result is triv.s:


.globl graph1
   .type graph1, @function
graph1:
   ...
   subq $32, %rsp      # space for stack frame
# --------- begin Your code -------
   movl $3,%eax        #  3 -> %eax
   movl %eax,-32(%rbp) #  i := %eax
# --------- begin Epilogue code ---
   leave
   ret