]>
Commit | Line | Data |
---|---|---|
030c2d18 HS |
1 | .. SPDX-License-Identifier: GPL-2.0+: |
2 | ||
60971e63 HS |
3 | .. index:: |
4 | single: cmp (command) | |
5 | ||
030c2d18 HS |
6 | cmp command |
7 | =========== | |
8 | ||
9 | Synopsis | |
10 | -------- | |
11 | ||
12 | :: | |
13 | ||
14 | cmp [.b, .w, .l, .q] addr1 addr2 count | |
15 | ||
16 | Description | |
17 | ----------- | |
18 | ||
19 | The cmp command is used to compare two memory areas. By default it works on | |
a356b50f HS |
20 | four byte (32-bit) values. By appending .b, .w, .l, .q the size of the |
21 | values is controlled: | |
030c2d18 HS |
22 | |
23 | cmp.b | |
a356b50f | 24 | compare 1 byte (8-bit) values |
030c2d18 HS |
25 | |
26 | cmp.w | |
a356b50f | 27 | compare 2 byte (16-bit) values |
030c2d18 HS |
28 | |
29 | cmp.l | |
a356b50f | 30 | compare 4 byte (32-bit) values |
030c2d18 HS |
31 | |
32 | cmp.q | |
a356b50f | 33 | compare 8 byte (64-bit) values |
030c2d18 HS |
34 | |
35 | The parameters are used as follows: | |
36 | ||
37 | addr1 | |
38 | Address of the first memory area. | |
39 | ||
40 | addr2 | |
41 | Address of the second memory area. | |
42 | ||
43 | count | |
44 | Number of bytes to compare (as hexadecimal number). | |
45 | ||
46 | Example | |
47 | ------- | |
48 | ||
49 | In the example below the strings "Hello world\n" and "Hello World\n" are written | |
50 | to memory and then compared. | |
51 | ||
52 | :: | |
53 | ||
54 | => mm.b 0x1000000 | |
55 | 01000000: 00 ? 48 | |
56 | 01000001: 00 ? 65 | |
57 | 01000002: 00 ? 6c | |
58 | 01000003: 00 ? 6c | |
59 | 01000004: 00 ? 6f | |
60 | 01000005: 00 ? 20 | |
61 | 01000006: 00 ? 77 | |
62 | 01000007: 00 ? 6f | |
63 | 01000008: 00 ? 72 | |
64 | 01000009: 00 ? 6c | |
65 | 0100000a: 00 ? 64 | |
66 | 0100000b: 00 ? 0d | |
67 | 0100000c: 00 ? => <INTERRUPT> | |
68 | => mm.b 0x101000 | |
69 | 00101000: 00 ? 48 | |
70 | 00101001: 00 ? 65 | |
71 | 00101002: 00 ? 6c | |
72 | 00101003: 00 ? 6c | |
73 | 00101004: 00 ? 6f | |
74 | 00101005: 00 ? 20 | |
75 | 00101006: 00 ? 57 | |
76 | 00101007: 00 ? 6f | |
77 | 00101008: 00 ? 72 | |
78 | 00101009: 00 ? 6c | |
79 | 0010100a: 00 ? 64 | |
80 | 0010100b: 00 ? 0d | |
81 | 0010100c: 00 ? => <INTERRUPT> | |
82 | => cmp 0x1000000 0x101000 0xc | |
83 | word at 0x01000004 (0x6f77206f) != word at 0x00101004 (0x6f57206f) | |
84 | Total of 1 word(s) were the same | |
85 | => cmp.b 0x1000000 0x101000 0xc | |
86 | byte at 0x01000006 (0x77) != byte at 0x00101006 (0x57) | |
87 | Total of 6 byte(s) were the same | |
88 | => cmp.w 0x1000000 0x101000 0xc | |
89 | halfword at 0x01000006 (0x6f77) != halfword at 0x00101006 (0x6f57) | |
90 | Total of 3 halfword(s) were the same | |
91 | => cmp.l 0x1000000 0x101000 0xc | |
92 | word at 0x01000004 (0x6f77206f) != word at 0x00101004 (0x6f57206f) | |
93 | Total of 1 word(s) were the same | |
94 | => cmp.q 0x1000000 0x101000 0xc | |
95 | double word at 0x01000000 (0x6f77206f6c6c6548) != double word at 0x00101000 (0x6f57206f6c6c6548) | |
96 | Total of 0 double word(s) were the same | |
97 | ||
98 | Configuration | |
99 | ------------- | |
100 | ||
101 | The cmp command is only available if CONFIG_CMD_MEMORY=y. The cmp.q command is | |
102 | only available if additionally CONFIG_MEM_SUPPORT_64BIT_DATA=y. | |
103 | ||
104 | Return value | |
105 | ------------ | |
106 | ||
107 | The return value $? is true (0) if the compared memory areas are equal. | |
108 | The reutrn value is false (1) if the compared memory areas differ. |