diff options
author | Russ Cox <rsc@swtch.com> | 2013-03-11 17:26:11 -0400 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2013-03-11 17:26:11 -0400 |
commit | 01e3847b7e6ff87f72a34a42cd98425e569250f6 (patch) | |
tree | 9d1e2b3abe36634593bc9a2c6009fd7c257a89b3 /src/cmd/xd.c | |
parent | 36bb28dc638bb3091e05996156b5fbecbc67dcd5 (diff) | |
download | plan9port-01e3847b7e6ff87f72a34a42cd98425e569250f6.tar.gz plan9port-01e3847b7e6ff87f72a34a42cd98425e569250f6.tar.bz2 plan9port-01e3847b7e6ff87f72a34a42cd98425e569250f6.zip |
xd: accept -S for 8-byte swap
R=rsc
https://codereview.appspot.com/7565045
Diffstat (limited to 'src/cmd/xd.c')
-rw-r--r-- | src/cmd/xd.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/cmd/xd.c b/src/cmd/xd.c index 3e8ba5d3..7be55b21 100644 --- a/src/cmd/xd.c +++ b/src/cmd/xd.c @@ -8,6 +8,7 @@ int ndata; unsigned long addr; int repeats; int swizzle; +int swizzle8; int flush; int abase=2; int xd(char *, int); @@ -83,6 +84,12 @@ main(int argc, char *argv[]) goto Usage; continue; } + if(argv[0][0] == 'S'){ + swizzle8 = 1; + if(argv[0][1]) + goto Usage; + continue; + } if(argv[0][0] == 'u'){ flush = 1; if(argv[0][1]) @@ -215,6 +222,8 @@ xd(char *name, int title) data[i] = 0; if(swizzle) swizz(); + if(swizzle8) + swizz8(); if(ndata==16 && repeats){ if(addr>0 && data[0]==odata[0]){ for(i=1; i<16; i++) @@ -277,6 +286,33 @@ swizz(void) } void +swizz8(void) +{ + uchar *p, *q; + int i; + uchar swdata[16]; + + p = data; + q = swdata; + for(i=0; i<16; i++) + *q++ = *p++; + p = data; + q = swdata; + for(i=0; i<8; i++){ + p[0] = q[7]; + p[1] = q[6]; + p[2] = q[5]; + p[3] = q[4]; + p[4] = q[3]; + p[5] = q[2]; + p[6] = q[1]; + p[7] = q[0]; + p += 8; + q += 8; + } +} + +void fmt0(char *f) { int i; |