misc_amips.s 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #*
  2. #* Some misc routines for Allegrex MIPS
  3. #* (C) notaz, 2007-2008
  4. #*
  5. #* This work is licensed under the terms of MAME license.
  6. #* See COPYING file in the top-level directory.
  7. #*
  8. .set noreorder
  9. .set noat
  10. .text
  11. .align 4
  12. .globl memset32 # int *dest, int c, int count
  13. memset32:
  14. ms32_aloop:
  15. andi $t0, $a0, 0x3f
  16. beqz $t0, ms32_bloop_prep
  17. nop
  18. sw $a1, 0($a0)
  19. addiu $a2, -1
  20. beqz $a2, ms32_return
  21. addiu $a0, 4
  22. j ms32_aloop
  23. nop
  24. ms32_bloop_prep:
  25. srl $t0, $a2, 4 # we will do 64 bytes per iteration (cache line)
  26. beqz $t0, ms32_bloop_end
  27. ms32_bloop:
  28. addiu $t0, -1
  29. cache 0x18, ($a0) # create dirty exclusive
  30. sw $a1, 0x00($a0)
  31. sw $a1, 0x04($a0)
  32. sw $a1, 0x08($a0)
  33. sw $a1, 0x0c($a0)
  34. sw $a1, 0x10($a0)
  35. sw $a1, 0x14($a0)
  36. sw $a1, 0x18($a0)
  37. sw $a1, 0x1c($a0)
  38. sw $a1, 0x20($a0)
  39. sw $a1, 0x24($a0)
  40. sw $a1, 0x28($a0)
  41. sw $a1, 0x2c($a0)
  42. sw $a1, 0x30($a0)
  43. sw $a1, 0x34($a0)
  44. sw $a1, 0x38($a0)
  45. sw $a1, 0x3c($a0)
  46. bnez $t0, ms32_bloop
  47. addiu $a0, 0x40
  48. ms32_bloop_end:
  49. andi $a2, $a2, 0x0f
  50. beqz $a2, ms32_return
  51. ms32_cloop:
  52. addiu $a2, -1
  53. sw $a1, 0($a0)
  54. bnez $a2, ms32_cloop
  55. addiu $a0, 4
  56. ms32_return:
  57. jr $ra
  58. nop
  59. .globl memset32_uncached # int *dest, int c, int count
  60. memset32_uncached:
  61. srl $t0, $a2, 3 # we will do 32 bytes per iteration
  62. beqz $t0, ms32u_bloop_end
  63. ms32u_bloop:
  64. addiu $t0, -1
  65. sw $a1, 0x00($a0)
  66. sw $a1, 0x04($a0)
  67. sw $a1, 0x08($a0)
  68. sw $a1, 0x0c($a0)
  69. sw $a1, 0x10($a0)
  70. sw $a1, 0x14($a0)
  71. sw $a1, 0x18($a0)
  72. sw $a1, 0x1c($a0)
  73. bnez $t0, ms32u_bloop
  74. addiu $a0, 0x20
  75. ms32u_bloop_end:
  76. andi $a2, $a2, 0x0f
  77. beqz $a2, ms32u_return
  78. ms32u_cloop:
  79. addiu $a2, -1
  80. sw $a1, 0($a0)
  81. bnez $a2, ms32u_cloop
  82. addiu $a0, 4
  83. ms32u_return:
  84. jr $ra
  85. nop
  86. # vim:filetype=mips