void spinlock (pulong -w pointer, MTX_* rw, MTX_* ps, ulong set_release)
           if (rw == MTX_READ && ps == MTX_PRIMARY && set_release == 1)
{
  int cntr = 0;

  while ()
  {
    ulong rc = 0; 

    asm () / R0, R24
    {
      SETPTR R24, pointer, DT_DWORD; LOADPTR R24, R24;                         /* R24 = pointer;       */
      SPINLOCK R0, R24, 1, MTX_READ, MTX_PRIMARY, MTX_LOCAL;                   /* R0 = lock (^R24, 1); */

      SETPTR R24, &rc, DT_DWORD;                                               /* R24 = ^rc;           */
      STORE R24, R0, DT_DWORD;                                                 /* R24^ = R0;           */
    }

    if (rc == 0)
    {
      if (cntr < 2^16) cntr ++;
      else sleep (0);
    }
    else
    {
      break;
    }
  }
}

void spinlock (pulong -w pointer, MTX_* rw, MTX_* ps, ulong set_release)
           if (rw == MTX_READ && ps == MTX_PRIMARY && set_release == 0)
{
  asm () / R0, R24
  {
    SETPTR R24, pointer, DT_DWORD; LOADPTR R24, R24;                           /* R24 = pointer;       */
    SPINLOCK R0, R24, 0, MTX_READ, MTX_PRIMARY, MTX_LOCAL;                     /* R0 = lock (^R24, 0); */
  }
}
