setjmp.S 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
  3. * Copyright (c) 2021 Loongson Technology Corporation Limited.All rights
  4. * reserved.
  5. * Author: zhoumingtao <[email protected]>
  6. *
  7. * This program and the accompanying materials are licensed and made
  8. * available
  9. * under the terms and conditions of the BSD License which accompanies
  10. * this
  11. * distribution. The full text of the license may be found at
  12. * http://opensource.org/licenses/bsd-license.php.
  13. *
  14. * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
  15. * BASIS,
  16. * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
  17. * IMPLIED.
  18. */
  19. .text
  20. .p2align 3
  21. /*
  22. int setjmp(jmp_buf env);
  23. */
  24. .globl setjmp
  25. .type setjmp, @function
  26. setjmp:
  27. st.d $ra, $a0, 0x0
  28. st.d $sp, $a0, 0x8
  29. st.d $fp, $a0, 0x10
  30. st.d $s0, $a0, 0x18
  31. st.d $s1, $a0, 0x20
  32. st.d $s2, $a0, 0x28
  33. st.d $s3, $a0, 0x30
  34. st.d $s4, $a0, 0x38
  35. st.d $s5, $a0, 0x40
  36. st.d $s6, $a0, 0x48
  37. st.d $s7, $a0, 0x50
  38. st.d $s8, $a0, 0x58
  39. move $a0, $zero
  40. jr $ra
  41. /*
  42. void longjmp(jmp_buf env, int val);
  43. */
  44. .globl longjmp
  45. .type longjmp, @function
  46. longjmp:
  47. ld.d $ra, $a0, 0x0
  48. ld.d $sp, $a0, 0x8
  49. ld.d $fp, $a0, 0x10
  50. ld.d $s0, $a0, 0x18
  51. ld.d $s1, $a0, 0x20
  52. ld.d $s2, $a0, 0x28
  53. ld.d $s3, $a0, 0x30
  54. ld.d $s4, $a0, 0x38
  55. ld.d $s5, $a0, 0x40
  56. ld.d $s6, $a0, 0x48
  57. ld.d $s7, $a0, 0x50
  58. ld.d $s8, $a0, 0x58
  59. addi.d $a0, $zero, 1 # a0 = 1
  60. beqz $a1, .L0 # if (a1 == 0); goto L0
  61. move $a0, $a1 # a0 = a1
  62. .L0:
  63. jr $ra