prt0.as 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. .file "prt0.c"
  2. .text
  3. .globl start
  4. .type start,@function
  5. start:
  6. pushl %ebp
  7. movl %esp,%ebp
  8. movl 16(%ebp),%ecx
  9. movl 12(%ebp),%ebx
  10. movl 8(%ebp),%eax
  11. movl %eax,operatingsystem_parameter_argc
  12. movl %ebx,operatingsystem_parameter_argv
  13. movl %ecx,operatingsystem_parameter_envp
  14. xorl %ebp,%ebp
  15. call PASCALMAIN
  16. .globl _haltproc
  17. .type _haltproc,@function
  18. _haltproc:
  19. xorl %ebx,%ebx
  20. movw operatingsystem_result,%bx
  21. pushl %ebx
  22. call sys_exit
  23. /* int sys_open (int=0xFF000000, char * name, int mode, int=0, int close_on_exec=0); */
  24. .globl sys_open
  25. .type sys_open,@function
  26. sys_open:
  27. xorl %eax,%eax
  28. int $0x25
  29. ret
  30. /* int sys_close (int handle) */
  31. .globl sys_close
  32. .type sys_close,@function
  33. sys_close:
  34. mov $0x01,%eax
  35. int $0x25
  36. ret
  37. /* int sys_read (int handle, void * buffer, int length) */
  38. .globl sys_read
  39. .type sys_read,@function
  40. sys_read:
  41. movl $0x02,%eax
  42. int $0x25
  43. ret
  44. /* int sys_write (int handle, void * buffer, int length) */
  45. .globl sys_write
  46. .type sys_write,@function
  47. sys_write:
  48. movl $0x3,%eax
  49. int $0x25
  50. ret
  51. /* int sys_lseek (int handle, long long pos, int whence) */
  52. .globl sys_lseek
  53. .type sys_lseek,@function
  54. sys_lseek:
  55. movl $0x5,%eax
  56. int $0x25
  57. ret
  58. /* int sys_time(void) */
  59. .globl sys_time
  60. .type sys_time,@function
  61. sys_time:
  62. movl $0x7,%eax
  63. int $0x25
  64. ret
  65. /* int sys_resize_area */
  66. .globl sys_resize_area
  67. .type sys_resize_area,@function
  68. sys_resize_area:
  69. movl $0x8,%eax
  70. int $0x25
  71. ret
  72. /* int sys_opendir (0xFF000000, chra * name, 0) */
  73. .globl sys_opendir
  74. .type sys_opendir,@function
  75. sys_opendir:
  76. movl $0xC,%eax
  77. int $0x25
  78. ret
  79. /* int sys_create_area */
  80. .globl sys_create_area
  81. .type sys_create_area,@function
  82. sys_create_area:
  83. movl $0x14,%eax
  84. int $0x25
  85. ret
  86. /* int sys_readdir (int handle, void * dirent, 0x11C, 0x01000000) */
  87. .globl sys_readdir
  88. .type sys_readdir,@function
  89. sys_readdir:
  90. movl $0x1C,%eax
  91. int $0x25
  92. ret
  93. /* int sys_mkdir (char=0xFF, char * name, int mode) */
  94. .globl sys_mkdir
  95. .type sys_mkdir,@function
  96. sys_mkdir:
  97. movl $0x1E,%eax
  98. int $0x25
  99. ret
  100. /* int sys_wait_for_thread */
  101. .globl sys_wait_for_thread
  102. .type sys_wait_for_thread,@function
  103. sys_wait_for_thread:
  104. movl $0x22,%eax
  105. int $0x25
  106. ret
  107. /* int sys_rename (int=0xFF000000, char * name, int=0xFF000000, char * newname) */
  108. .globl sys_rename
  109. .type sys_rename,@function
  110. sys_rename:
  111. movl $0x26,%eax
  112. int $0x25
  113. ret
  114. /* int sys_unlink (int=0xFF000000, char * name) */
  115. .globl sys_unlink
  116. .type sys_unlink,@function
  117. sys_unlink:
  118. movl $0x27,%eax
  119. int $0x25
  120. ret
  121. /* int sys_stat (int=0xFF000000, char * name, struct stat * s, int=0) */
  122. .globl sys_stat
  123. .type sys_stat,@function
  124. sys_stat:
  125. movl $0x30,%eax
  126. int $0x25
  127. ret
  128. /* int sys_load_image */
  129. .globl sys_load_image
  130. .type sys_load_image,@function
  131. sys_load_image:
  132. movl $0x34,%eax
  133. int $0x25
  134. ret
  135. /* void sys_exit (int exitcode) */
  136. .globl sys_exit
  137. .type sys_exit,@function
  138. sys_exit:
  139. movl $0x3F,%eax
  140. int $0x25
  141. /* void sys_chdir (char 0xFF, char * name) */
  142. .globl sys_chdir
  143. .type sys_chdir,@function
  144. sys_chdir:
  145. movl $0x57,%eax
  146. int $0x25
  147. ret
  148. /* void sys_rmdir (char 0xFF, char * name) */
  149. .globl sys_rmdir
  150. .type sys_rmdir,@function
  151. sys_rmdir:
  152. movl $0x60,%eax
  153. int $0x25
  154. ret
  155. /* actual syscall */
  156. .globl sys_call
  157. .type sys_call,@function
  158. sys_call:
  159. int $0x25
  160. ret
  161. .bss
  162. .comm operatingsystem_parameter_envp,4
  163. .comm operatingsystem_parameter_argc,4
  164. .comm operatingsystem_parameter_argv,4