1
/=============================================================================
2
/ tas.s -- test and set lock for solaris_i386
3
/=============================================================================
12
pushl %ebp /save prev base pointer
13
movl %esp,%ebp /new base pointer
14
pushl %ebx /save prev bx
15
movl 8(%ebp),%ebx /load bx with address of lock
16
movl $255,%eax /put something in ax
17
xchgb %al,(%ebx) /swap lock value with "0"
18
cmpb $0,%al /did we get the lock?
20
subl %eax,%eax /yes, we got it -- return 0
24
movl $1,%eax /no, we didn't get it - return 1
26
popl %ebx /restore prev bx
27
movl %ebp,%esp /restore stack state