Advertisement
cfrantz

Untitled

Nov 19th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. ## Added 'import' and module support:
  2.  
  3.  
  4. cfrantz@bunk:~/src/lang/df$ cat hello2.df
  5.  
  6. import stdio;
  7.  
  8. // Program entry at main
  9. main() -> int32 {
  10. stdio::printf("Hello World\n");
  11. return 0;
  12. }
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19. cfrantz@bunk:~/src/lang/df$ cat hello2.s
  20.  
  21. SECTION .data
  22. str_2:
  23. DB 72,101,108,108,111,32,87,111,114,108,100,10,0
  24. SECTION .text
  25. ;
  26. ; hello2.df:0: import stdio;
  27. ;
  28. ;
  29. ; builtin/stdio.df:2: printf: extern __magic__("alias:printf") (format: &uint8, ...) -> int32;
  30. ;
  31. %define stdio$printf printf
  32. EXTERN printf
  33. ;
  34. ; hello2.df:3: main() -> int32 {
  35. ;
  36. GLOBAL main
  37. main:
  38. PUSH ebp
  39. MOV ebp, esp
  40. AND esp, -16
  41. SUB esp, 32
  42. MOV [ebp-4], ebx
  43. MOV [ebp-8], esi
  44. MOV [ebp-12], edi
  45. ;
  46. ; hello2.df:4: stdio::printf("Hello World\n");
  47. ;
  48. MOV eax, str_2
  49. MOV [esp+0], eax
  50. CALL stdio$printf
  51. ;
  52. ; hello2.df:5: return 0;
  53. ;
  54. MOV eax, 0
  55. fnexit_main_1:
  56. MOV ebx, [ebp-4]
  57. MOV esi, [ebp-8]
  58. MOV edi, [ebp-12]
  59. MOV esp, ebp
  60. POP ebp
  61. RET
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement