3 char buffer
[] ="0123456789abcdef";
4 char target
[] ="XXXXXXXXXXXXXXXX";
12 printf("------- Copy 10+1 bytes from buffer to target\n");
13 printf("------- EX to OR in the length\n");
14 printf("before: buffer = |%s|\n", buffer
);
15 printf("before: target = |%s|\n", target
);
16 asm volatile( "larl 1, 1f\n\t"
21 "mvc 0(1,%0),0(%1)\n\t"
23 : : "a" (target
), "a" (buffer
): "1", "2", "memory");
24 printf("after: buffer = |%s|\n", buffer
);
25 printf("after: target = |%s|\n", target
);
28 printf("------- EX 0,... has no effect (writes out target)\n");
29 printf(" target = |");
30 asm volatile( "lghi 0, 0xff\n\t" // fill nonsense in r0
32 "lghi 2, 1\n\t" // stdout
33 "lgr 3, %0\n\t" // target
34 "lghi 4, %1\n\t" // len
40 : : "a" (target
), "i" (sizeof target
- 1)
41 : "0", "1", "2", "3", "4");
45 printf("------- EX to OR in the syscall number (writes out target)\n");
46 printf(" target = |");
47 asm volatile( "lghi 5, 4\n\t" // NR_write
49 "lghi 2, 1\n\t" // stdout
50 "lgr 3, %0\n\t" // target
51 "lghi 4, %1\n\t" // len
55 "svc 0\n\t" // changed to NR_write
57 : : "a" (target
), "i" (sizeof target
- 1)
58 : "1", "2", "3", "4", "5");
62 printf("------- EX targeting a PC-relative instruction\n");
63 asm volatile( "1:\n\t"
70 printf(" offset = |%016lx|\n", offset
);
73 printf("------- EX targeting a branch-and-link instruction\n");
74 asm volatile( "larl 1,1f\n\t"
83 printf(" offset = |%016lx|\n", offset
);