sysutilp.inc 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 2001 by Jonas Maebe,
  5. member of the Free Pascal development team
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. { ---------------------------------------------------------------------
  13. This include contains cpu-specific routines
  14. ---------------------------------------------------------------------}
  15. function InterLockedDecrement (var Target: integer) : Integer; assembler;
  16. { input: address of target in r3 }
  17. { output: target-1 in r3 }
  18. { side-effect: target := target-1 }
  19. asm
  20. InterLockedDecLoop:
  21. lwarx r10,r10,r3
  22. subi r10,r10,1
  23. stwcx. r10,r10,r3
  24. bne InterLockedDecLoop
  25. mr r3,r10
  26. end;
  27. function InterLockedIncrement (var Target: integer) : Integer; assembler;
  28. { input: address of target in r3 }
  29. { output: target+1 in r3 }
  30. { side-effect: target := target+1 }
  31. asm
  32. InterLockedIncLoop:
  33. lwarx r10,r10,r3
  34. addi r10,r10,1
  35. stwcx. r10,r10,r3
  36. bne InterLockedIncLoop
  37. mr r3,r10
  38. end;
  39. function InterLockedExchange (var Target: integer;Source : integer) : Integer; assembler;
  40. { input: address of target in r3, source in r4 }
  41. { output: target in r3 }
  42. { side-effect: target := source }
  43. asm
  44. InterLockedXchgLoop:
  45. lwarx r10,r10,r3
  46. stwcx. r4,r10,r3
  47. bne InterLockedXchgLoop
  48. mr r3,r10
  49. end;
  50. function InterLockedExchangeAdd (var Target: integer;Source : integer) : Integer; assembler;
  51. { input: address of target in r3, source in r4 }
  52. { output: target in r3 }
  53. { side-effect: target := target+source }
  54. asm
  55. InterLockedXchgAddLoop:
  56. lwarx r10,r10,r3
  57. add r10,r10,r4
  58. stwcx. r10,r10,r3
  59. bne InterLockedXchgAddLoop
  60. sub r3,r10,r4
  61. end;
  62. {
  63. $Log$
  64. Revision 1.4 2003-08-24 20:50:11 olle
  65. * changed used scratchreg from r0 to r10
  66. Revision 1.3 2003/04/24 12:13:23 florian
  67. * fixed assembler errors
  68. Revision 1.2 2002/09/07 16:01:26 peter
  69. * old logs removed and tabs fixed
  70. }