#include <9pm/u.h>
#include <9pm/libc.h>
#undef lock

void
incref(Ref *ref)
{
	_asm {
		mov eax, ref
		lock inc [eax]
	}
}

int
decref(Ref *ref)
{
	int x;

	_asm {
		mov eax, ref
		lock dec [eax]
		jz iszero
		mov x, 1
		jmp retrn
	iszero:
		mov x, 0
	retrn:
	}
	return x;
}


syntax highlighted by Code2HTML, v. 0.9.1