arm.inc 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2003 by the Free Pascal development team.
  5. Processor dependent implementation for the system unit for
  6. ARM
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  9. This program 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.
  12. **********************************************************************}
  13. {$asmmode gas}
  14. procedure fpc_cpuinit;
  15. begin
  16. asm
  17. rfs r0
  18. and r0,r0,#0xffe0ffff
  19. orr r0,r0,#0x00020000
  20. wfs r0
  21. end;
  22. end;
  23. {****************************************************************************
  24. stack frame related stuff
  25. ****************************************************************************}
  26. {$define FPC_SYSTEM_HAS_GET_FRAME}
  27. function get_frame:pointer;assembler;nostackframe;{$ifdef SYSTEMINLINE}inline;{$endif}
  28. asm
  29. mov r0,r11
  30. end ['R0'];
  31. {$define FPC_SYSTEM_HAS_GET_CALLER_ADDR}
  32. function get_caller_addr(framebp:pointer):pointer;assembler;{$ifdef SYSTEMINLINE}inline;{$endif}
  33. asm
  34. movs r0,r0
  35. beq .Lg_a_null
  36. ldr r0,[r0,#-4]
  37. .Lg_a_null:
  38. end ['R0'];
  39. {$define FPC_SYSTEM_HAS_GET_CALLER_FRAME}
  40. function get_caller_frame(framebp:pointer):pointer;assembler;{$ifdef SYSTEMINLINE}inline;{$endif}
  41. asm
  42. movs r0,r0
  43. beq .Lgnf_null
  44. ldr r0,[r0,#-12]
  45. .Lgnf_null:
  46. end ['R0'];
  47. {$define FPC_SYSTEM_HAS_SPTR}
  48. Function Sptr : pointer;assembler;{$ifdef SYSTEMINLINE}inline;{$endif}
  49. asm
  50. mov r0,sp
  51. end ['R0'];
  52. {$define FPC_SYSTEM_HAS_FILLCHAR}
  53. Procedure FillChar(var x;count:longint;value:byte);assembler;nostackframe;
  54. asm
  55. // less than 0?
  56. cmp r1,#0
  57. movlt pc,lr
  58. mov r3,r0
  59. cmp r1,#8 // at least 8 bytes to do?
  60. blt .LFillchar2
  61. orr r2,r2,r2,lsl #8
  62. orr r2,r2,r2,lsl #16
  63. .LFillchar0:
  64. tst r3,#3 // aligned yet?
  65. strneb r2,[r3],#1
  66. subne r1,r1,#1
  67. bne .LFillchar0
  68. mov ip,r2
  69. .LFillchar1:
  70. cmp r1,#8 // 8 bytes still to do?
  71. blt .LFillchar2
  72. stmia r3!,{r2,ip}
  73. sub r1,r1,#8
  74. cmp r1,#8 // 8 bytes still to do?
  75. blt .LFillchar2
  76. stmia r3!,{r2,ip}
  77. sub r1,r1,#8
  78. cmp r1,#8 // 8 bytes still to do?
  79. blt .LFillchar2
  80. stmia r3!,{r2,ip}
  81. sub r1,r1,#8
  82. cmp r1,#8 // 8 bytes still to do?
  83. stmgeia r3!,{r2,ip}
  84. subge r1,r1,#8
  85. bge .LFillchar1
  86. .LFillchar2:
  87. movs r1,r1 // anything left?
  88. moveq pc,lr
  89. rsb r1,r1,#7
  90. add pc,pc,r1,lsl #2
  91. mov r0,r0
  92. strb r2,[r3],#1
  93. strb r2,[r3],#1
  94. strb r2,[r3],#1
  95. strb r2,[r3],#1
  96. strb r2,[r3],#1
  97. strb r2,[r3],#1
  98. strb r2,[r3],#1
  99. mov pc,lr
  100. end;
  101. {
  102. $Log$
  103. Revision 1.10 2005-01-05 15:59:02 florian
  104. + added nostackframe directive to get_frame
  105. Revision 1.9 2005/01/05 15:21:14 florian
  106. * fillchar fixed; it's used now
  107. Revision 1.8 2005/01/04 16:46:38 florian
  108. + correct setting of FPU exception mask
  109. Revision 1.7 2004/03/23 21:03:10 florian
  110. + assembler implementation of fpc_mul_qword
  111. * fpu exceptions are now generated
  112. Revision 1.6 2004/03/14 21:45:11 florian
  113. * draft for qword mul
  114. Revision 1.5 2004/01/21 23:12:07 florian
  115. + get_caller_addr/frame implemented
  116. Revision 1.4 2004/01/20 21:01:57 florian
  117. * fixed setjump
  118. * fixed syscalls
  119. Revision 1.3 2003/11/21 00:40:06 florian
  120. * some arm issues fixed
  121. Revision 1.2 2003/09/03 14:09:37 florian
  122. * arm fixes to the common rtl code
  123. * some generic math code fixed
  124. * ...
  125. Revision 1.1 2003/08/21 16:41:54 florian
  126. * empty dummy files
  127. + [long|set]jmp implemented
  128. }