mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-24 11:41:58 +00:00
xd: accept -S for 8-byte swap
R=rsc https://codereview.appspot.com/7565045
This commit is contained in:
parent
36bb28dc63
commit
01e3847b7e
2 changed files with 39 additions and 0 deletions
|
@ -75,6 +75,9 @@ Print file addresses in the given style (and size 4).
|
||||||
.B -s
|
.B -s
|
||||||
Reverse (swab) the order of bytes in each group of 4 before printing.
|
Reverse (swab) the order of bytes in each group of 4 before printing.
|
||||||
.TP
|
.TP
|
||||||
|
.B -S
|
||||||
|
Reverse the order of bytes in each group of 8 before printing.
|
||||||
|
.TP
|
||||||
.B -r
|
.B -r
|
||||||
Print repeating groups of identical 16-byte sequences as the first group
|
Print repeating groups of identical 16-byte sequences as the first group
|
||||||
followed by an asterisk.
|
followed by an asterisk.
|
||||||
|
|
36
src/cmd/xd.c
36
src/cmd/xd.c
|
@ -8,6 +8,7 @@ int ndata;
|
||||||
unsigned long addr;
|
unsigned long addr;
|
||||||
int repeats;
|
int repeats;
|
||||||
int swizzle;
|
int swizzle;
|
||||||
|
int swizzle8;
|
||||||
int flush;
|
int flush;
|
||||||
int abase=2;
|
int abase=2;
|
||||||
int xd(char *, int);
|
int xd(char *, int);
|
||||||
|
@ -83,6 +84,12 @@ main(int argc, char *argv[])
|
||||||
goto Usage;
|
goto Usage;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if(argv[0][0] == 'S'){
|
||||||
|
swizzle8 = 1;
|
||||||
|
if(argv[0][1])
|
||||||
|
goto Usage;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if(argv[0][0] == 'u'){
|
if(argv[0][0] == 'u'){
|
||||||
flush = 1;
|
flush = 1;
|
||||||
if(argv[0][1])
|
if(argv[0][1])
|
||||||
|
@ -215,6 +222,8 @@ xd(char *name, int title)
|
||||||
data[i] = 0;
|
data[i] = 0;
|
||||||
if(swizzle)
|
if(swizzle)
|
||||||
swizz();
|
swizz();
|
||||||
|
if(swizzle8)
|
||||||
|
swizz8();
|
||||||
if(ndata==16 && repeats){
|
if(ndata==16 && repeats){
|
||||||
if(addr>0 && data[0]==odata[0]){
|
if(addr>0 && data[0]==odata[0]){
|
||||||
for(i=1; i<16; i++)
|
for(i=1; i<16; i++)
|
||||||
|
@ -276,6 +285,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
|
void
|
||||||
fmt0(char *f)
|
fmt0(char *f)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue