libc-full.M1 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ## Copyright (C) 2020 deesix <deesix@tuta.io>
  2. ## This file is part of M2-Planet.
  3. ##
  4. ## M2-Planet is free software: you can redistribute it and/or modify
  5. ## it under the terms of the GNU General Public License as published by
  6. ## the Free Software Foundation, either version 3 of the License, or
  7. ## (at your option) any later version.
  8. ##
  9. ## M2-Planet is distributed in the hope that it will be useful,
  10. ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ## GNU General Public License for more details.
  13. ##
  14. ## You should have received a copy of the GNU General Public License
  15. ## along with M2-Planet. If not, see <http://www.gnu.org/licenses/>.
  16. :_start
  17. INIT_SP
  18. LDR_X0_[SP]
  19. ADD_X1_SP_8
  20. SET_BP_FROM_SP
  21. PUSH_X0
  22. PUSH_X1
  23. SET_X1_TO_2
  24. ADD_X0_X1_X0
  25. SET_X1_TO_8
  26. MUL_X0_X1_X0
  27. ADD_X0_BP_X0
  28. PUSH_X0
  29. ;; Setup for _envp
  30. LOAD_W1_AHEAD
  31. SKIP_32_DATA
  32. &GLOBAL__envp
  33. STR_X0_[X1]
  34. ;; Setup for malloc
  35. LOAD_W16_AHEAD
  36. SKIP_32_DATA
  37. &FUNCTION___init_malloc
  38. BLR_X16
  39. ;; Setup for FILE*
  40. LOAD_W16_AHEAD
  41. SKIP_32_DATA
  42. &FUNCTION___init_io
  43. BLR_X16
  44. ;; Call main
  45. LOAD_W16_AHEAD
  46. SKIP_32_DATA
  47. &FUNCTION_main
  48. BLR_X16
  49. POP_X1
  50. POP_X1
  51. POP_X1
  52. PUSH_X0 ; Put return on the stack
  53. PUSH_X0 ; So that _exit has it
  54. PUSH_X0 ; So that _exit has it
  55. :FUNCTION_exit
  56. LOAD_W16_AHEAD
  57. SKIP_32_DATA
  58. &FUNCTION___kill_io
  59. BLR_X16
  60. :FUNCTION__exit
  61. SET_X0_FROM_BP
  62. SUB_X0_8
  63. DEREF_X0
  64. SET_X8_TO_SYS_EXIT
  65. SYSCALL
  66. :GLOBAL__envp
  67. NULL