int64p.inc 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by the Free Pascal development team
  5. This file contains some helper routines for int64 and qword
  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. {$define FPC_SYSTEM_HAS_MUL_QWORD}
  13. function fpc_mul_qword(f1,f2 : qword;checkoverflow : longbool) : qword;assembler;[public,alias: 'FPC_MUL_QWORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
  14. asm
  15. mov r6,#0
  16. // lo(f1)*lo(f2)
  17. umull r4,r5,r0,r2
  18. // lo(f1)*hi(f2)
  19. umlal r5,r6,r0,r3
  20. // overflow?
  21. // hi(f1)*hi(f2)
  22. mul r0,r1,r3
  23. // hi(f1)*lo(f2)
  24. umlal r5,r6,r1,r2
  25. // check for overflow
  26. orrs r6,r6,r0
  27. mov r0,r4
  28. mov r1,r5
  29. // no overflow?
  30. beq .Lexit
  31. ldr r2,checkoverflow
  32. cmp r2,#0
  33. beq .Lexit
  34. mov r0,#215
  35. mov r1,fp
  36. bl HandleErrorFrame
  37. .Lexit:
  38. end ['r4','r5','r6'];
  39. {
  40. $Log$
  41. Revision 1.4 2005-01-04 12:57:52 florian
  42. * fixed overflow checking for qword*qword
  43. Revision 1.3 2004/03/23 21:03:11 florian
  44. + assembler implementation of fpc_mul_qword
  45. * fpu exceptions are now generated
  46. Revision 1.2 2004/03/14 21:45:11 florian
  47. * draft for qword mul
  48. Revision 1.1 2003/11/03 17:28:21 florian
  49. * initial revision
  50. }