1*f9b29c63SIlya Leoshkevich /* 2*f9b29c63SIlya Leoshkevich * Test the TEST AND SET instruction. 3*f9b29c63SIlya Leoshkevich * 4*f9b29c63SIlya Leoshkevich * SPDX-License-Identifier: GPL-2.0-or-later 5*f9b29c63SIlya Leoshkevich */ 6*f9b29c63SIlya Leoshkevich #include <assert.h> 7*f9b29c63SIlya Leoshkevich #include <stdlib.h> 8*f9b29c63SIlya Leoshkevich ts(char * p)9*f9b29c63SIlya Leoshkevichstatic int ts(char *p) 10*f9b29c63SIlya Leoshkevich { 11*f9b29c63SIlya Leoshkevich int cc; 12*f9b29c63SIlya Leoshkevich 13*f9b29c63SIlya Leoshkevich asm("ts %[p]\n" 14*f9b29c63SIlya Leoshkevich "ipm %[cc]" 15*f9b29c63SIlya Leoshkevich : [cc] "=r" (cc) 16*f9b29c63SIlya Leoshkevich , [p] "+Q" (*p) 17*f9b29c63SIlya Leoshkevich : : "cc"); 18*f9b29c63SIlya Leoshkevich 19*f9b29c63SIlya Leoshkevich return (cc >> 28) & 3; 20*f9b29c63SIlya Leoshkevich } 21*f9b29c63SIlya Leoshkevich main(void)22*f9b29c63SIlya Leoshkevichint main(void) 23*f9b29c63SIlya Leoshkevich { 24*f9b29c63SIlya Leoshkevich char c; 25*f9b29c63SIlya Leoshkevich 26*f9b29c63SIlya Leoshkevich c = 0x80; 27*f9b29c63SIlya Leoshkevich assert(ts(&c) == 1); 28*f9b29c63SIlya Leoshkevich assert(c == 0xff); 29*f9b29c63SIlya Leoshkevich 30*f9b29c63SIlya Leoshkevich c = 0x7f; 31*f9b29c63SIlya Leoshkevich assert(ts(&c) == 0); 32*f9b29c63SIlya Leoshkevich assert(c == 0xff); 33*f9b29c63SIlya Leoshkevich 34*f9b29c63SIlya Leoshkevich return EXIT_SUCCESS; 35*f9b29c63SIlya Leoshkevich } 36