tas.s 377 B

123456789101112131415161718192021
  1. #include <sys/regdef.h>
  2. #include <sys/asm.h>
  3. .globl tas
  4. .ent tas 2
  5. tas:
  6. .set noreorder
  7. 1:
  8. ori t1, zero, 12345 /* t1 = 12345 */
  9. ll t0, (a0) /* t0 = *a0 */
  10. sc t1, (a0) /* *a0 = t1 if *a0 hasn't changed; t1=success */
  11. beq t1, zero, 1b /* repeat if *a0 did change */
  12. nop
  13. j $31 /* return */
  14. or v0, t0, zero /* set return value on way out */
  15. .set reorder
  16. .end tas