Home | History | Annotate | Download | only in s390x
      1 #include <stdio.h>
      2 
      3 char base[] ="0123456789012345678901234567890123456789";
      4 
      5 void
      6 stmg_no_wrap(void)
      7 {
      8    char buf[24];
      9 
     10    /* No-wrap around case; copies 24 bytes from BASE to BUF */
     11    asm volatile( "lg   5,  0(%1)\n\t"
     12                  "lg   6,  8(%1)\n\t"
     13                  "lg   7, 16(%1)\n\t"
     14                  "stmg 5, 7, %0\n\t"
     15                  :"=m" (buf)
     16                  : "a" (base)
     17                  : "5", "6", "7");
     18    /* Write out BUF */
     19    asm volatile( "lghi 2, 1\n\t"   // stdout
     20                  "lgr  3, %0\n\t"  // buf
     21                  "lghi 4, 24\n\t"  // len = 3*8 bytes
     22                  "svc  4\n\t"
     23                  : : "a" (buf)
     24                  : "2", "3", "4");
     25 }
     26 
     27 void
     28 stmg_wrap(void)
     29 {
     30    char buf[64];
     31 
     32    /* Wrap around case; copies 32 bytes from BASE to BUF */
     33    asm volatile( "lg   15,  0(%1)\n\t"
     34                  "lg    0,  8(%1)\n\t"
     35                  "lg    1, 16(%1)\n\t"
     36                  "lg    2, 24(%1)\n\t"
     37                  "stmg 15, 2, %0\n\t"
     38                  :"=m" (buf)
     39                  : "a" (base)
     40                  : "15", "0", "1", "2");
     41    /* Write out BUF */
     42    asm volatile( "lghi 2, 1\n\t"   // stdout
     43                  "lgr  3, %0\n\t"  // buf
     44                  "lghi 4, 32\n\t"  // len = 4*8 bytes
     45                  "svc  4\n\t"
     46                  : : "a" (buf)
     47                  : "2", "3", "4");
     48 }
     49 
     50 
     51 int main(void)
     52 {
     53    stmg_no_wrap();
     54    printf("\n");
     55    stmg_wrap();
     56    printf("\n");
     57 
     58    return 0;
     59 }
     60