1 #include <stdio.h> 2 3 char buffer[] ="0123456789abcdef"; 4 char target[] ="XXXXXXXXXXXXXXXX"; 5 6 int main(void) 7 { 8 setbuf(stdout, NULL); 9 10 printf("------- Copy 10+1 bytes from buffer to target\n"); 11 printf("------- EXRL to OR in the length\n"); 12 printf("before: buffer = |%s|\n", buffer); 13 printf("before: target = |%s|\n", target); 14 asm volatile( "lghi 2, 10\n\t" 15 ".insn ril,0xc60000000000,2,1f\n\t" // exrl 2, 1f 16 "j 2f\n\t" 17 "1:\n\t" 18 "mvc 0(1,%0),0(%1)\n\t" 19 "2:\n\t" 20 : : "a" (target), "a" (buffer) : "1", "2", "memory"); 21 printf("after: buffer = |%s|\n", buffer); 22 printf("after: target = |%s|\n", target); 23 printf("\n"); 24 25 printf("------- EXRL 0,... has no effect (writes out target)\n"); 26 printf(" target = |"); 27 asm volatile( "lghi 0, 0xff\n\t" // fill nonsense in r0 28 "lghi 2, 1\n\t" // stdout 29 "lgr 3, %0\n\t" // target 30 "lghi 4, %1\n\t" // len 31 ".insn ril,0xc60000000000,0,1f\n\t" // exrl 0, 1f 32 "j 2f\n\t" 33 "1:\n\t" 34 "svc 4\n\t" // NR_write 35 "2:\n\t" 36 : : "a" (target), "i" (sizeof target - 1) 37 : "0", "2", "3", "4"); 38 printf("|\n"); 39 printf("\n"); 40 41 printf("------- EXRL to OR in the syscall number (writes out target)\n"); 42 printf(" target = |"); 43 asm volatile( "lghi 1, 4\n\t" // NR_write 44 "lghi 2, 1\n\t" // stdout 45 "lgr 3, %0\n\t" // target 46 "lghi 4, %1\n\t" // len 47 ".insn ril,0xc60000000000,1,1f\n\t" // exrl 1, 1f 48 "j 2f\n\t" 49 "1:\n\t" 50 "svc 0\n\t" // changed to NR_write 51 "2:\n\t" 52 : : "a" (target), "i" (sizeof target - 1) 53 : "1", "2", "3", "4"); 54 printf("|\n"); 55 printf("\n"); 56 57 return 0; 58 } 59 60