Guest User

Untitled

a guest
May 28th, 2016
75
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/28/2016 02:12:27.
  5. ; ============================================================================
  6.  
  7. ; Variables are not supported yet.
  8.  
  9. ; Functions:
  10. main:
  11.     bpget
  12.     spget
  13.     bpset
  14.     ; void
  15.     push 33
  16.     cpget
  17.     jmp @print_str
  18.     drop ; str
  19.     push 0
  20.     drop
  21.  
  22.     ; void
  23.     push 33
  24.     cpget
  25.     jmp @print_str_native
  26.     drop ; str
  27.     push 0
  28.     drop
  29.  
  30.     bpget
  31.     spset
  32.     bpset
  33.     ret
  34.  
  35. print_str:
  36.     bpget
  37.     spget
  38.     bpset
  39.     ; int
  40.     get -3  ; local str
  41.     store 8  [r:push] ; global i
  42.     drop
  43.  
  44.     ; EinCompiler.LoopInstruction
  45.     ; begin while
  46. __internal__label0:
  47.     push 1  [f:yes]
  48.     [ex(z)=1] jmp @__internal__label1
  49.     ; int
  50.     push 0
  51.     load 8  ; global i
  52.     cpget
  53.     jmp @read_mem
  54.     drop ; ptr
  55.     store 0  [r:push] ; global x
  56.     drop
  57.  
  58.     ; EinCompiler.ConditionalInstruction
  59.     ; if condition
  60.     load 0  [f:yes]  ; global x
  61.     [ex(z)=1] jmp @__internal__label2 ; Jump to false
  62.     jmp @__internal__label3; jump to end
  63. __internal__label2:
  64.     ; EinCompiler.BreakLoopInstruction
  65.     jmp @__internal__label1; break
  66.  
  67. __internal__label3:
  68.  
  69.     ; void
  70.     load 0  ; global x
  71.     cpget
  72.     jmp @putc
  73.     drop ; ptr
  74.     push 0
  75.     drop
  76.  
  77.     ; int
  78.     push 1
  79.     load 8  ; global i
  80.     add
  81.     store 8  [r:push] ; global i
  82.     drop
  83.  
  84.     jmp @__internal__label0 ; end while
  85. __internal__label1:
  86.  
  87.     bpget
  88.     spset
  89.     bpset
  90.     ret
  91.  
  92. print_str_native:
  93.  
  94.     bpget
  95.     spget
  96.     bpset
  97.  
  98.     get -3
  99. print_str_loop:
  100.     [i0:peek] loadi [f:yes] ; write flags, also load result, don't discard pointer
  101.     [ex(z)=1] jmp @print_str_end_loop ; when *ptr == 0, then goto print_str_end_loop
  102.     [i0:pop] syscall [ci:1] ; removes the loaded character and prints it
  103.     [i0:arg] add 1 ; adds 1 to the stack top
  104.     jmp @print_str_loop
  105. print_str_end_loop:
  106.     drop ; discard the result from loadi
  107.     drop ; discard our pointer
  108.    
  109.     bpget ; leave function
  110.     spset ; by restoring parent base pointer
  111.     bpset
  112.     jmpi  ; and jumping back.
  113. read_mem:
  114.  
  115.     bpget
  116.     spget
  117.     bpset
  118.  
  119.     get -3 ; Get address
  120.     loadi
  121.     set -4 ; Set return value
  122.  
  123.     bpget
  124.     spset
  125.     bpset
  126.     jmpi
  127. putc:
  128.  
  129.     bpget
  130.     spget
  131.     bpset
  132.  
  133.     get -3; Get address
  134.     [i0:pop] syscall [ci:1]
  135.  
  136.     bpget
  137.     spset
  138.     bpset
  139.     jmpi
Advertisement
Add Comment
Please, Sign In to add comment