36 lines
1.4 KiB
Text
36 lines
1.4 KiB
Text
%swap: proc(x,y);
|
|
dcl (x, y) char;
|
|
|
|
x = trim(x); /* Just for neatness sake */
|
|
y = trim(y);
|
|
|
|
ans('begin; ') skip;
|
|
ans(' dcl c char (1); ') skip;
|
|
ans(' dcl sx char (1) based(px); ') skip;
|
|
ans(' dcl sy char (1) based(py); ') skip;
|
|
ans(' dcl i fixed bin (31); ') skip;
|
|
ans(' dcl px ptr init (addr(' || x || ')); ') skip;
|
|
ans(' dcl py ptr init (addr(' || y || ')); ') skip;
|
|
ans(' do i = 1 to min(stg(' || x || '), stg(' || y || '));') skip;
|
|
ans(' c = sx; ') skip;
|
|
ans(' sx = sy; ') skip;
|
|
ans(' sy = c; ') skip;
|
|
ans(' px = px + 1; ') skip;
|
|
ans(' py = py + 1; ') skip;
|
|
ans(' end; ') skip;
|
|
ans('end; ') skip;
|
|
%end swap;
|
|
%act swap;
|
|
|
|
dcl c1 char (10) init ('1234567890');
|
|
dcl c2 char (10) init ('ABCDEFGHIJ');
|
|
dcl f1 fixed bin (31) init (12345);
|
|
dcl f2 fixed bin (31) init (98765);
|
|
|
|
put data(c1, c2, f1, f2);
|
|
swap(c1, c2);
|
|
swap(f1, f2);
|
|
put data(c1, c2, f1, f2);
|
|
f1 = -656877352; /* '5a5a5a5a'x, aka 'QQQQ' */
|
|
swapper(c1, f1);
|
|
put data(c1,f1);
|