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