umaxdi3.S 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. ; Copyright (C) 2017-2022 Free Software Foundation, Inc.
  2. ; Contributed by Sebastian Perta.
  3. ;
  4. ; This file is free software; you can redistribute it and/or modify it
  5. ; under the terms of the GNU General Public License as published by the
  6. ; Free Software Foundation; either version 3, or (at your option) any
  7. ; later version.
  8. ;
  9. ; This file is distributed in the hope that it will be useful, but
  10. ; WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. ; General Public License for more details.
  13. ;
  14. ; Under Section 7 of GPL version 3, you are granted additional
  15. ; permissions described in the GCC Runtime Library Exception, version
  16. ; 3.1, as published by the Free Software Foundation.
  17. ;
  18. ; You should have received a copy of the GNU General Public License and
  19. ; a copy of the GCC Runtime Library Exception along with this program;
  20. ; see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
  21. ; <http://www.gnu.org/licenses/>.
  22. #include "vregs.h"
  23. .text
  24. START_FUNC ___umaxdi3
  25. ; copy first argument/operand to the output registers
  26. movw ax, [sp+4]
  27. movw r8, ax
  28. movw ax, [sp+6]
  29. movw r10, ax
  30. movw ax, [sp+8]
  31. movw r12, ax
  32. movw ax, [sp+10]
  33. movw r14, ax
  34. ; use 16-bit compares from the most significant words downto the least significant ones
  35. movw ax, [sp+18]
  36. cmpw ax, r14
  37. bh $.L1
  38. bnz $.L2
  39. movw ax, [sp+16]
  40. cmpw ax, r12
  41. bh $.L1
  42. bnz $.L2
  43. movw ax, [sp+14]
  44. cmpw ax, r10
  45. bh $.L1
  46. bnz $.L2
  47. movw ax, [sp+12]
  48. cmpw ax, r8
  49. bh $.L1
  50. ret
  51. .L1:
  52. ; copy second argument/operand to the output registers
  53. movw ax, [sp+12]
  54. movw r8, ax
  55. movw ax, [sp+14]
  56. movw r10, ax
  57. movw ax, [sp+16]
  58. movw r12, ax
  59. movw ax, [sp+18]
  60. movw r14, ax
  61. .L2:
  62. ret
  63. END_FUNC ___umaxdi3