Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. (define p_mult
  2. '((fun (multiply x y)
  3. (vars
  4. []
  5. (return (* x y))))
  6. (fun (main)
  7. (vars
  8. [(x 6) (y 7)]
  9. (print (multiply x y))
  10. (return 0)))))
  11.  
  12. '((jump _f_main)
  13. (data ST-PTR END-PROG)
  14. (data ST-PTR2 0)
  15. (label _f_multiply)
  16. (const _x0 3)
  17. (const _y0 4)
  18. (move (5 ST-PTR) (_x0 ST-PTR))
  19. (move (6 ST-PTR) (_y0 ST-PTR))
  20. (mul (7 ST-PTR) (5 ST-PTR) (6 ST-PTR))
  21. (move (1 ST-PTR) (7 ST-PTR))
  22. (jump (0 ST-PTR))
  23. (const frame-size-0 8)
  24. (label _f_main)
  25. (const _x1 3)
  26. (move (_x1 ST-PTR) 6)
  27. (const _y1 4)
  28. (move (_y1 ST-PTR) 7)
  29. (add ST-PTR2 ST-PTR frame-size-1)
  30. (const RETURN_LOC0 L0)
  31. (move (0 ST-PTR2) RETURN_LOC0)
  32. (move (2 ST-PTR2) ST-PTR)
  33. (move (7 ST-PTR) (_x1 ST-PTR))
  34. (move (3 ST-PTR2) (7 ST-PTR))
  35. (move (8 ST-PTR) (_y1 ST-PTR))
  36. (move (4 ST-PTR2) (8 ST-PTR))
  37. (move ST-PTR ST-PTR2)
  38. (jump _f_multiply)
  39. (label L0)
  40. (move ST-PTR2 ST-PTR)
  41. (move ST-PTR (2 ST-PTR))
  42. (move (8 ST-PTR) (1 ST-PTR2))
  43. (print-val (8 ST-PTR))
  44. (move (9 ST-PTR) 0)
  45. (move (1 ST-PTR) (9 ST-PTR))
  46. (jump (0 ST-PTR))
  47. (const frame-size-1 10)
  48. (label END-PROG)
  49. 1
  50. (data FILLER (5000 0)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement