Alternative library and kernel for add-in development on fx-9860G and fx-CG50 under Linux.
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.
 
 
 
 
 
 

71 lines
902 B

  1. .global _memset
  2. .text
  3. _memset:
  4. tst r6, r6
  5. bt .zero
  6. /* We'll fill from the end */
  7. mov r4, r3
  8. add r6, r4
  9. /* When setting less than 64 bytes, use the naive method */
  10. mov #64, r0
  11. cmp/ge r6, r0
  12. bt _naive_memset
  13. mov #3, r2
  14. /* Make a 4-byte filler */
  15. mov r5, r0
  16. shll8 r5
  17. or r5, r0
  18. mov r0, r5
  19. shll16 r5
  20. or r5, r0
  21. _memset_align:
  22. /* 4-align the destination */
  23. mov.b r0, @-r4
  24. tst r2, r4
  25. bf/s _memset_align
  26. dt r6
  27. mov #40, r2
  28. .aligned4_32:
  29. add #-32, r4
  30. add #-32, r6
  31. mov.l r0, @(28,r4)
  32. mov.l r0, @(24,r4)
  33. mov.l r0, @(20,r4)
  34. mov.l r0, @(16,r4)
  35. mov.l r0, @(12,r4)
  36. mov.l r0, @(8,r4)
  37. mov.l r0, @(4,r4)
  38. cmp/ge r6, r2
  39. bf/s .aligned4_32
  40. mov.l r0, @r4
  41. mov #8, r2
  42. .aligned4_4:
  43. mov.l r0, @-r4
  44. cmp/ge r6, r2
  45. bf/s .aligned4_4
  46. add #-4, r6
  47. _naive_memset:
  48. /* Tight loop copy one byte */
  49. dt r6
  50. bf/s _naive_memset
  51. mov.b r5, @-r4
  52. .end:
  53. rts
  54. mov r3, r0
  55. .zero:
  56. rts
  57. mov r4, r0