You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

start.S 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Derived from the Hyperstone's library source code.
  3. * Copyright (C) 2002-2003 GDT, Yannis Mitsos <gmitsos@telecom.ntua.gr>
  4. * George Thanos <gthanos@telecom.ntua.gr>
  5. */
  6. .global Priority ; Task-Priority
  7. .global _Stack1Size ; Size of hardware stack
  8. .global _Stack2Size ; Size of aggregate stack
  9. .global _Stack1Base ; Base of hardware stack
  10. .global _Stack2Base ; Base of aggregate stack
  11. .global _Mem0HeapBase ; Base of Heap in Mem0
  12. .global _Mem1HeapBase ; Base of Heap in Mem1
  13. .global _init_peripherals
  14. .global _main
  15. .global Main
  16. .global __exit
  17. .global __fmode
  18. .global __MaxArgCount
  19. .text
  20. BasePtrs:
  21. .weak G6Base,G7Base,G8Base,G9Base,G10Base,G11Base,G12Base,G13Base
  22. .long G6Base,G7Base,G8Base,G9Base,G10Base,G11Base,G12Base,G13Base
  23. BasePtrsEnd:
  24. HeapPtrs:
  25. .long _Mem0HeapBase
  26. .long _Mem1HeapBase
  27. HeapPtrsEnd:
  28. __MaxArgCount:
  29. .long 32
  30. __StandAloneMode:
  31. .long 0 ; 0 indicate stand alone mode
  32. ;============================================================================;
  33. ; Startup-Code ;
  34. ;============================================================================;
  35. .data
  36. ; do not change the order of: __argc,..
  37. __argc:
  38. .long 0
  39. __argv:
  40. .long 0
  41. __IsShell:
  42. .long 1
  43. ErrorLevel:
  44. .long 0
  45. __lab:
  46. .long 0
  47. __fmode:
  48. .long 0x4000 ; O_TEXT attribute
  49. _isa_drivers:
  50. .long 0
  51. _isa_drivers_end:
  52. .long 0
  53. .text
  54. Main:
  55. StartUp:
  56. FRAME L5, L0
  57. MOVI L2, __bss_start__ ; clear the .bss segment
  58. 0: CMPI L2, __bss_end__
  59. BHE 0f
  60. DBR 0b
  61. STW.P L2, 0
  62. 0: SUM L2, PC, BasePtrs-$ ; Load BasePtrs G6-G13
  63. LDD.P L2, G6
  64. LDD.P L2, G8
  65. ; LDD.P L2, G10
  66. LDD.P L2, G12
  67. MOVI L2, 1
  68. SUM L3, PC, __StandAloneMode-$
  69. STW.R L3, L2
  70. ;----------------------------------------------------------------;
  71. ; Call main C function ;
  72. ;----------------------------------------------------------------;
  73. 2: LDW.D PC, L2, __argc - $ ; pass count of arguments to main
  74. LDW.D PC, L3, __argv - $ ; pass pointer array to main
  75. CALL L4, PC, _init_peripherals - $
  76. CALL L4, PC, _main - $ ; --> Call Main-Program
  77. CHK PC, PC ; trap if execution arrives here
  78. __exit:
  79. FRAME L5, L1
  80. STW.D PC, L0, ErrorLevel - $ ; Store ERRORLEVEL
  81. CHK PC, PC
  82. RET PC, L1
  83. .global ___main
  84. ___main:
  85. FRAME L4, L1
  86. MOVI L3, 2
  87. STW.D PC, L3, __StandAloneMode-$
  88. RET PC, L1 ; does not return
  89. .section _GOT_
  90. .long Main+4 ; OnCreate
  91. .long Main+8 ; OnError
  92. .long BasePtrs ; G6
  93. .long BasePtrs+4 ; G7
  94. .long BasePtrs+8 ; G8
  95. .END