]> git.lizzy.rs Git - plan9front.git/blob - sys/src/libc/386/atom.s
audiohda: make it work with sb600 onboard sound
[plan9front.git] / sys / src / libc / 386 / atom.s
1 TEXT ainc(SB), $0       /* long ainc(long *); */
2         MOVL    addr+0(FP), BX
3 ainclp:
4         MOVL    (BX), AX
5         MOVL    AX, CX
6         INCL    CX
7         LOCK
8         BYTE    $0x0F; BYTE $0xB1; BYTE $0x0B   /* CMPXCHGL CX, (BX) */
9         JNZ     ainclp
10         MOVL    CX, AX
11         RET
12
13 TEXT adec(SB), $0       /* long adec(long*); */
14         MOVL    addr+0(FP), BX
15 adeclp:
16         MOVL    (BX), AX
17         MOVL    AX, CX
18         DECL    CX
19         LOCK
20         BYTE    $0x0F; BYTE $0xB1; BYTE $0x0B   /* CMPXCHGL CX, (BX) */
21         JNZ     adeclp
22         MOVL    CX, AX
23         RET
24
25 /*
26  * int cas32(u32int *p, u32int ov, u32int nv);
27  * int cas(uint *p, int ov, int nv);
28  * int casp(void **p, void *ov, void *nv);
29  * int casl(ulong *p, ulong ov, ulong nv);
30  */
31
32 /*
33  * CMPXCHG (CX), DX: 0000 1111 1011 000w oorr rmmm,
34  * mmm = CX = 001; rrr = DX = 010
35  */
36
37 #define CMPXCHG         BYTE $0x0F; BYTE $0xB1; BYTE $0x11
38
39 TEXT    cas32+0(SB),0,$0
40 TEXT    cas+0(SB),0,$0
41 TEXT    casp+0(SB),0,$0
42 TEXT    casl+0(SB),0,$0
43         MOVL    p+0(FP), CX
44         MOVL    ov+4(FP), AX
45         MOVL    nv+8(FP), DX
46         LOCK
47         CMPXCHG
48         JNE     fail
49         MOVL    $1,AX
50         RET
51 fail:
52         MOVL    $0,AX
53         RET
54
55 /*
56  * int cas64(u64int *p, u64int ov, u64int nv);
57  */
58
59 /*
60  * CMPXCHG64 (DI): 0000 1111 1100 0111 0000 1110,
61  */
62
63 #define CMPXCHG64               BYTE $0x0F; BYTE $0xC7; BYTE $0x0F
64
65 TEXT    cas64+0(SB),0,$0
66         MOVL    p+0(FP), DI
67         MOVL    ov+0x4(FP), AX
68         MOVL    ov+0x8(FP), DX
69         MOVL    nv+0xc(FP), BX
70         MOVL    nv+0x10(FP), CX
71         LOCK
72         CMPXCHG64
73         JNE     fail
74         MOVL    $1,AX
75         RET