".quad 5b\n" \
"7:\n"
-static int bic0(int i)
+static long bic0(long i)
{
void *table;
asm volatile(HEAD
return i;
}
-static int bic4(int i)
+static long bic4(long i)
{
void *table;
asm volatile(HEAD
return i;
}
-static int bic15(int i)
+static long bic15(long i)
{
void *table;
asm volatile(HEAD
int main()
{
- int i;
+ long i;
for (i = 0; i < 16; i++) {
- printf("bic0: %d -> %d\n", i, bic0(i));
- printf("bic4: %d -> %d\n", i, bic4(i));
- printf("bic15: %d -> %d\n", i, bic15(i));
+ printf("bic0: %ld -> %ld\n", i, bic0(i));
+ printf("bic4: %ld -> %ld\n", i, bic4(i));
+ printf("bic15: %ld -> %ld\n", i, bic15(i));
}
}
register uint64_t reg2 asm("2") = (uint64_t) buff;
register uint64_t reg3 asm("3") = len;
- asm volatile( " lhi 4,42\n\t"
- " xr 4,4\n\t" /* set cc to != 0 */
+ asm volatile( " cr 0,0\n\t" /* set cc to 0 */
"0: cksm %0,%1\n\t" /* do checksum on longs */
" jo 0b\n\t"
- : "+d" (sum), "+d" (reg2), "+d" (reg3) : : "cc", "memory");
+ : "+d" (sum), "+a" (reg2), "+a" (reg3) : : "cc");
cc = get_cc();
len = reg3;
/* At least one character will be written to BUFF, i.e. loop in jitted
code is iterated */
run_test(buff, 4, pattern1, sizeof pattern1);
- run_test(buff, 5, pattern1, sizeof pattern2);
- run_test(buff, 6, pattern1, sizeof pattern3);
- run_test(buff, 7, pattern1, sizeof pattern4);
+ run_test(buff, 5, pattern1, sizeof pattern1);
+ run_test(buff, 6, pattern1, sizeof pattern1);
+ run_test(buff, 7, pattern1, sizeof pattern1);
/* Convert buffer with mixed characters */
printf("\n------------- test4 ----------------\n");
cc = 1
dst address difference: 4 dst len: 0
src address difference: 2 src len: 2
-UTF8: 00 01 02 03 c2 80 c2 81
+UTF8: 00 01 02 03
UTF16: 0000 0001
cc = 1
dst address difference: 4 dst len: 1
- src address difference: 2 src len: 6
-UTF8: 00 01 02 03 c2 80 c2 81 c2 82 c2 83
+ src address difference: 2 src len: 2
+UTF8: 00 01 02 03
UTF16: 0000 0001 0002
cc = 1
dst address difference: 6 dst len: 0
- src address difference: 3 src len: 9
-UTF8: 00 01 02 03 c2 80 c2 81 c2 82 c2 83 e1 80 80 e1
+ src address difference: 3 src len: 1
+UTF8: 00 01 02 03
UTF16: 0000 0001 0002
cc = 1
dst address difference: 6 dst len: 1
- src address difference: 3 src len: 13
+ src address difference: 3 src len: 1
------------- test4 ----------------
UTF8: 01 c3 80 12 e1 90 93 23 f4 80 90 8a 34 c4 8c e1 91 94 c5 8a f4 80 90 8a c5 8a e1 91 94 f4 80 90 8a e1 91 94
cc = 1
dst address difference: 4 dst len: 0
src address difference: 2 src len: 2
-UTF8: 00 01 02 03 c2 80 c2 81
+UTF8: 00 01 02 03
UTF16: 0000 0001
cc = 1
dst address difference: 4 dst len: 1
- src address difference: 2 src len: 6
-UTF8: 00 01 02 03 c2 80 c2 81 c2 82 c2 83
+ src address difference: 2 src len: 2
+UTF8: 00 01 02 03
UTF16: 0000 0001 0002
cc = 1
dst address difference: 6 dst len: 0
- src address difference: 3 src len: 9
-UTF8: 00 01 02 03 c2 80 c2 81 c2 82 c2 83 e1 80 80 e1
+ src address difference: 3 src len: 1
+UTF8: 00 01 02 03
UTF16: 0000 0001 0002
cc = 1
dst address difference: 6 dst len: 1
- src address difference: 3 src len: 13
+ src address difference: 3 src len: 1
------------- test4 ----------------
UTF8: 01 c3 80 12 e1 90 93 23 f4 80 90 8a 34 c4 8c e1 91 94 c5 8a f4 80 90 8a c5 8a e1 91 94 f4 80 90 8a e1 91 94
/* At least one character will be written to BUFF, i.e. loop in jitted
code is iterated */
run_test(buff, 4, pattern1, sizeof pattern1);
- run_test(buff, 5, pattern1, sizeof pattern2);
- run_test(buff, 6, pattern1, sizeof pattern3);
- run_test(buff, 7, pattern1, sizeof pattern4);
+ run_test(buff, 5, pattern1, sizeof pattern1);
+ run_test(buff, 6, pattern1, sizeof pattern1);
+ run_test(buff, 7, pattern1, sizeof pattern1);
/* Convert buffer with mixed characters */
printf("\n------------- test4 ----------------\n");
cc = 1
dst address difference: 4 dst len: 0
src address difference: 1 src len: 3
-UTF8: 00 01 02 03 c2 80 c2 81
+UTF8: 00 01 02 03
UTF32: 00000000
cc = 1
dst address difference: 4 dst len: 1
- src address difference: 1 src len: 7
-UTF8: 00 01 02 03 c2 80 c2 81 c2 82 c2 83
+ src address difference: 1 src len: 3
+UTF8: 00 01 02 03
UTF32: 00000000
cc = 1
dst address difference: 4 dst len: 2
- src address difference: 1 src len: 11
-UTF8: 00 01 02 03 c2 80 c2 81 c2 82 c2 83 e1 80 80 e1
+ src address difference: 1 src len: 3
+UTF8: 00 01 02 03
UTF32: 00000000
cc = 1
dst address difference: 4 dst len: 3
- src address difference: 1 src len: 15
+ src address difference: 1 src len: 3
------------- test4 ----------------
UTF8: 01 c3 80 12 e1 90 93 23 f4 80 90 8a 34 c4 8c e1 91 94 c5 8a f4 80 90 8a c5 8a e1 91 94 f4 80 90 8a e1 91 94
cc = 1
dst address difference: 4 dst len: 0
src address difference: 1 src len: 3
-UTF8: 00 01 02 03 c2 80 c2 81
+UTF8: 00 01 02 03
UTF32: 00000000
cc = 1
dst address difference: 4 dst len: 1
- src address difference: 1 src len: 7
-UTF8: 00 01 02 03 c2 80 c2 81 c2 82 c2 83
+ src address difference: 1 src len: 3
+UTF8: 00 01 02 03
UTF32: 00000000
cc = 1
dst address difference: 4 dst len: 2
- src address difference: 1 src len: 11
-UTF8: 00 01 02 03 c2 80 c2 81 c2 82 c2 83 e1 80 80 e1
+ src address difference: 1 src len: 3
+UTF8: 00 01 02 03
UTF32: 00000000
cc = 1
dst address difference: 4 dst len: 3
- src address difference: 1 src len: 15
+ src address difference: 1 src len: 3
------------- test4 ----------------
UTF8: 01 c3 80 12 e1 90 93 23 f4 80 90 8a 34 c4 8c e1 91 94 c5 8a f4 80 90 8a c5 8a e1 91 94 f4 80 90 8a e1 91 94
static unsigned long hex_to_dec(signed int num)
{
- unsigned long addr = 0;
-
- asm volatile(
- " cvd %2,%0"
- : "=m" (addr) : "a" (&addr) , "d" (num) : "memory");
- return addr;
+ unsigned long dec;
+ asm ("cvd %1,%0" : "=S" (dec) : "d" (num) : );
+ return dec;
}
int main()
"ipm %[psw]\n\t"
"stg 2, %[bitpos]\n\t"
"stg 3, %[modval]\n\t"
- : [bitpos]"=m"(*bitpos), [modval]"=m"(*modval),
+ : [bitpos]"=T"(*bitpos), [modval]"=T"(*modval),
[psw]"=&d"(psw)
: [val] "d"(value)
: "2", "3", "cc");
"ipm %[psw]\n\t"
"stg 2, %[bitpos]\n\t"
"stg 3, %[modval]\n\t"
- : [bitpos]"=m"(*bitpos), [modval]"=m"(*modval),
+ : [bitpos]"=T"(*bitpos), [modval]"=T"(*modval),
[psw]"=&d"(psw), [val] "+d"(value)
:
: "3", "cc");
"ipm %[psw]\n\t"
"stg 2, %[bitpos]\n\t"
"stg 3, %[modval]\n\t"
- : [bitpos]"=m"(*bitpos), [modval]"=m"(*modval),
+ : [bitpos]"=T"(*bitpos), [modval]"=T"(*modval),
[psw]"=&d"(psw), [val] "+d"(value)
:
: "2", "cc");
int mvst(void *targetp, void *source)
{
+ register int eos asm("0") = '\0';
asm volatile(
- " lhi 0, 0\n"
" mvst %0, %1\n"
- ::"a" (targetp),"a" (source): "0", "memory", "cc");
+ : "+a"(targetp), "+a"(source) : "d"(eos) : "memory", "cc");
return get_cc();
}
int mvst_full(void *targetp, void *source)
{
+ register int eos asm("0") = '\0';
asm volatile(
- " lhi 0, 0\n"
"0: mvst %0, %1\n"
" jo 0b\n"
- ::"a" (targetp),"a" (source): "0", "memory", "cc");
+ : "+a"(targetp), "+a"(source) : "d"(eos) : "memory", "cc");
return get_cc();
}
{
unsigned fpc;
- __asm__ volatile ("stfpc %0\n\t" : "=m"(fpc));
+ __asm__ volatile ("stfpc %0" : "=Q"(fpc));
return fpc & 0x7;
}
{
unsigned fpc;
- __asm__ volatile ("stfpc %0\n\t" : "=m"(fpc));
+ __asm__ volatile ("stfpc %0" : "=Q"(fpc));
return fpc & 0x7;
}
"srnm " #d "(8)\n\t" ::: "8"); \
})
-unsigned
-get_rounding_mode(void)
-{
- unsigned fpc;
-
- __asm__ volatile ("stfpc %0\n\t" : "=m"(fpc));
-
- return fpc & 0x7;
-}
+#define get_rounding_mode() \
+ ({ \
+ unsigned fpc; \
+ __asm__ volatile ("stfpc %0" : "=Q"(fpc)); \
+ fpc & 0x7; \
+ })
int main(void)
{
::: "0"); \
})
-unsigned
-get_rounding_mode(void)
-{
- unsigned fpc;
-
- __asm__ volatile ("stfpc %0\n\t" : "=m"(fpc));
-
- return fpc & 0x7;
-}
+#define get_rounding_mode() \
+ ({ \
+ unsigned fpc; \
+ __asm__ volatile ("stfpc %0" : "=Q"(fpc)); \
+ fpc & 0x7; \
+ })
int main(void)
{
Emulation warning: unsupported action:
The specified rounding mode is invalid.
Continuing using 'round to nearest'. Results may differ!
- at 0x........: main (srnmb.c:64)
+ at 0x........: main (srnmb.c:61)
::: "0"); \
})
-unsigned
-get_dfp_rounding_mode(void)
-{
- unsigned fpc;
-
- __asm__ volatile ("stfpc %0\n\t" : "=m"(fpc));
+#define get_dfp_rounding_mode() \
+ ({ \
+ unsigned fpc; \
+ __asm__ volatile ("stfpc %0" : "=Q"(fpc)); \
+ (fpc & 0x70) >> 4; \
+ })
- return (fpc & 0x70) >> 4;
-}
int main(void)
{
unsigned long long stfle(unsigned long dw, unsigned bit_to_test)
{
- unsigned long long hoststfle[S390_NUM_FACILITY_DW], match;
+ unsigned long long hoststfle[S390_NUM_FACILITY_DW];
register unsigned long long __nr asm("0") = dw - 1;
int cc;
asm volatile(" .insn s,0xb2b00000,%0 \n" /* stfle */
"ipm %2\n"
"srl %2,28\n"
- : "=m" (*hoststfle), "+d" (__nr), "=d" (cc) : : "cc", "memory");
+ : "=Q" (*hoststfle), "+d" (__nr), "=d" (cc) : : "cc", "memory");
printf("the value of cc is %d and #double words is %llu\n", cc, __nr + 1);
if (bit_to_test < 64)
- match = (hoststfle[0] & (1ULL << (63 - bit_to_test)));
+ return (hoststfle[0] & (1ULL << (63 - bit_to_test)));
else if (bit_to_test < 128)
- match = (hoststfle[1] & (1ULL << (63 - bit_to_test)));
+ return (hoststfle[1] & (1ULL << (63 - bit_to_test)));
else if (bit_to_test < 192)
- match = (hoststfle[2] & (1ULL << (63 - bit_to_test)));
- else
- printf("code needs to be updated\n");
+ return (hoststfle[2] & (1ULL << (63 - bit_to_test)));
- return match;
+ printf("code needs to be updated\n");
+ return 0;
}
int main()
#include <stdio.h>
-char base[] ="0123456789012345678901234567890123456789";
+static const union words {
+ char c[5 * 8];
+ unsigned long i[5];
+} base = { .c = "0123456789abcdefghijklmnopqrstuvwxyzABCD" },
+ init = { .c = "._,-'-._,-'-._,-'-._,-'-._,-'-._,-'-._,-" };
-void
-stmg_no_wrap(void)
+static void stmg_no_wrap(void)
{
- char buf[24];
+ union words buf = init;
+ register unsigned long a asm("5") = base.i[0];
+ register unsigned long b asm("6") = base.i[1];
+ register unsigned long c asm("7") = base.i[2];
/* No-wrap around case; copies 24 bytes from BASE to BUF */
- asm volatile( "lg 5, 0(%1)\n\t"
- "lg 6, 8(%1)\n\t"
- "lg 7, 16(%1)\n\t"
- "stmg 5, 7, %0\n\t"
- :"=m" (buf)
- : "a" (base)
- : "5", "6", "7");
+ asm ("stmg %[a], %[c], %[buf]"
+ : [buf] "=S"(buf)
+ : [a] "d"(a), "d"(b), [c] "d"(c)
+ : );
+
/* Write out BUF */
- fwrite(buf, sizeof(buf), 1, stdout);
+ fwrite(buf.c, sizeof(buf), 1, stdout);
}
-void
-stmg_wrap(void)
+static void stmg_wrap(void)
{
- char buf[32];
-
- /* Wrap around case; copies 32 bytes from BASE to BUF */
- asm volatile( "lgr 3, 15\n\t" /* save stack pointer */
- "lg 0, 8(%1)\n\t"
- "lg 1, 16(%1)\n\t"
- "lg 2, 24(%1)\n\t"
- "lg 15, 0(%1)\n\t"
- "stmg 15, 2, %0\n\t"
- "lgr 15, 3" /* restore stack pointer */
- :"=S" (buf)
- : "a" (base)
- : "0", "1", "2", "3");
+ union words buf = init;
+ register unsigned long sp asm("15");
+ register unsigned long a asm("0") = base.i[2];
+ register unsigned long b asm("1") = base.i[3];
+ register unsigned long c asm("2") = base.i[4];
+
+ /* Wrap around case: avoid changing r15, but ensure it's stored */
+ asm ("stmg 15, %[c], %[buf]"
+ : [buf] "=S"(buf), "=d"(sp)
+ : "d"(a), "d"(b), [c] "d"(c)
+ : );
+ buf.i[0] ^= sp ^ base.i[1];
+
/* Write out BUF */
- fwrite(buf, sizeof(buf), 1, stdout);
+ fwrite(buf.c, sizeof(buf), 1, stdout);
}
-012345678901234567890123
-01234567890123456789012345678901
+0123456789abcdefghijklmn._,-'-._,-'-._,-
+89abcdefghijklmnopqrstuvwxyzABCD,-'-._,-
"4: mvi %0,3\n\t" \
" j 0f\n\t" \
"0: bcr 0,0 /*nop*/\n\t" \
- :"=m" (__cc)::"memory"); \
+ :"=Q" (__cc)::"memory"); \
__cc; \
})
"4: mvi %0,3\n\t" \
"j 0f\n\t" \
"0: /* nop */ brc 0,0\n\t" \
- : "=m" (__cc) : : "memory"); \
+ : "=Q" (__cc) : : "memory"); \
__cc; \
})
"4: mvi %0,3\n\t" \
"j 0f\n\t" \
"0: /* nop */ brc 0,0\n\t" \
- : "=m" (__cc) : : "memory"); \
+ : "=Q" (__cc) : : "memory"); \
__cc; \
})