Guest User

SVMA Compilation

a guest
May 27th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; ============================================================================
  2. ; Code generated by EinCompiler.
  3. ; Generator: SVMABackEnd
  4. ; Date:      05/27/2016 18:33:51.
  5. ; ============================================================================
  6.  
  7. ; Variables are not supported yet.
  8.  
  9. ; Functions:
  10. main:
  11.         bpget
  12.         spget
  13.         bpset
  14.         bpget
  15.         spset
  16.         bpset
  17.         ret
  18.  
  19. test_expressions:
  20.         bpget
  21.         spget
  22.         bpset
  23.         ; int
  24.         push 1
  25.         store ??? [r:push] ; x
  26.         drop
  27.         ; int
  28.         load 0 ; TODO: Insert variable address
  29.         store ??? [r:push] ; x
  30.         drop
  31.         ; int
  32.         push 2
  33.         push 1
  34.         add
  35.         store ??? [r:push] ; x
  36.         drop
  37.         ; int
  38.         push 1
  39.         load 36 ; TODO: Insert variable address
  40.         add
  41.         store ??? [r:push] ; x
  42.         drop
  43.         ; int
  44.         load 36 ; TODO: Insert variable address
  45.         push 1
  46.         add
  47.         store ??? [r:push] ; x
  48.         drop
  49.         ; int
  50.         load 36 ; TODO: Insert variable address
  51.         load 36 ; TODO: Insert variable address
  52.         add
  53.         store ??? [r:push] ; x
  54.         drop
  55.         ; int
  56.         push 3
  57.         push 2
  58.         add
  59.         push 1
  60.         add
  61.         store ??? [r:push] ; x
  62.         drop
  63.         ; int
  64.         push 3
  65.         push 2
  66.         push 1
  67.         mul
  68.         add
  69.         store ??? [r:push] ; x
  70.         drop
  71.         ; int
  72.         push 3
  73.         push 2
  74.         mul
  75.         push 1
  76.         add
  77.         store ??? [r:push] ; x
  78.         drop
  79.         ; int
  80.         push 1
  81.         store ??? [r:push] ; x
  82.         drop
  83.         ; int
  84.         load 36 ; TODO: Insert variable address
  85.         store ??? [r:push] ; x
  86.         drop
  87.         ; int
  88.         push 2
  89.         push 1
  90.         add
  91.         store ??? [r:push] ; x
  92.         drop
  93.         ; int
  94.         push 3
  95.         push 2
  96.         add
  97.         push 1
  98.         mul
  99.         store ??? [r:push] ; x
  100.         drop
  101.         ; int
  102.         push 4
  103.         push 3
  104.         add
  105.         push 2
  106.         sub
  107.         push 1
  108.         mul
  109.         store ??? [r:push] ; x
  110.         drop
  111.         bpget
  112.         spset
  113.         bpset
  114.         ret
  115.  
  116. test_return:
  117.         bpget
  118.         spget
  119.         bpset
  120.         ; EinCompiler.ReturnInstruction
  121.         load 40 ; TODO: Insert variable address
  122.         load 40 ; TODO: Insert variable address
  123.         mul
  124.         set ??? ; TODO: Insert return value position here.
  125.         bpget
  126.         spset
  127.         bpset
  128.         ret
  129.         bpget
  130.         spset
  131.         bpset
  132.         ret
  133.  
  134. test_if:
  135.         bpget
  136.         spget
  137.         bpset
  138.         ; EinCompiler.ConditionalInstruction
  139.         ; if condition
  140.         push 2
  141.         push 1
  142.         add [f:yes]
  143.         [ex(z)=0] jmp @__internal__label1 ; Jump to end
  144.         ; int
  145.         load 32 ; TODO: Insert variable address
  146.         store ??? [r:push] ; i
  147.         drop
  148.         ; int
  149.         load 32 ; TODO: Insert variable address
  150.         store ??? [r:push] ; i
  151.         drop
  152. __internal__label1:
  153.         ; EinCompiler.ConditionalInstruction
  154.         ; if condition
  155.         push 2
  156.         push 1
  157.         add [f:yes]
  158.         [ex(z)=0] jmp @__internal__label2 ; Jump to false
  159.         ; int
  160.         load 32 ; TODO: Insert variable address
  161.         store ??? [r:push] ; i
  162.         drop
  163.         ; int
  164.         load 32 ; TODO: Insert variable address
  165.         store ??? [r:push] ; i
  166.         drop
  167.         jmp @__internal__label3; jump to end
  168. __internal__label2:
  169.         ; int
  170.         load 32 ; TODO: Insert variable address
  171.         store ??? [r:push] ; i
  172.         drop
  173. __internal__label3:
  174.         bpget
  175.         spset
  176.         bpset
  177.         ret
  178.  
  179. test_while:
  180.         bpget
  181.         spget
  182.         bpset
  183.         ; EinCompiler.LoopInstruction
  184.         ; begin while
  185. __internal__label4:
  186.         load 40 ; TODO: Insert variable address
  187.         load 40 ; TODO: Insert variable address
  188.         mul [f:yes]
  189.         [ex(z)=1] jmp @__internal__label5
  190.         ; int
  191.         load 32 ; TODO: Insert variable address
  192.         store ??? [r:push] ; i
  193.         drop
  194.         ; int
  195.         push 10
  196.         push 10
  197.         mul
  198.         store ??? [r:push] ; i
  199.         drop
  200.         jmp @__internal__label4 ; end while
  201. __internal__label5:
  202.         ; EinCompiler.LoopInstruction
  203.         ; begin while
  204. __internal__label6:
  205.         load 40 ; TODO: Insert variable address
  206.         load 40 ; TODO: Insert variable address
  207.         mul [f:yes]
  208.         [ex(z)=1] jmp @__internal__label7
  209.         ; EinCompiler.BreakLoopInstruction
  210. break;
  211.         ; EinCompiler.NopInstruction
  212.         nop
  213.         jmp @__internal__label6 ; end while
  214. __internal__label7:
  215.         bpget
  216.         spset
  217.         bpset
  218.         ret
  219.  
  220. test_call:
  221.         bpget
  222.         spget
  223.         bpset
  224.         ; int
  225. sum(    push 10
  226. ,       push 5
  227.         push 5
  228.         add
  229. )       drop
  230.         ; int
  231. sum(    push 10
  232. ,       push 5
  233.         push 5
  234.         add
  235. )       store ??? [r:push] ; i
  236.         drop
  237.         bpget
  238.         spset
  239.         bpset
  240.         ret
  241.  
  242. sum:
  243.         bpget
  244.         spget
  245.         bpset
  246.         ; EinCompiler.ReturnInstruction
  247.         get -2 ; TODO: Insert variable address
  248.         get -1 ; TODO: Insert variable address
  249.         add
  250.         set ??? ; TODO: Insert return value position here.
  251.         bpget
  252.         spset
  253.         bpset
  254.         ret
  255.         bpget
  256.         spset
  257.         bpset
  258.         ret
  259.  
  260. square:
  261.         bpget
  262.         spget
  263.         bpset
  264.         ; EinCompiler.ReturnInstruction
  265.         get -1 ; TODO: Insert variable address
  266.         get -1 ; TODO: Insert variable address
  267.         mul
  268.         set ??? ; TODO: Insert return value position here.
  269.         bpget
  270.         spset
  271.         bpset
  272.         ret
  273.         bpget
  274.         spset
  275.         bpset
  276.         ret
Advertisement
Add Comment
Please, Sign In to add comment