Heinrich Schuchardt | 50cd4ce | 2022-11-13 13:27:32 +0100 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+: |
| 2 | |
| 3 | cmp command |
| 4 | =========== |
| 5 | |
| 6 | Synopsis |
| 7 | -------- |
| 8 | |
| 9 | :: |
| 10 | |
| 11 | cmp [.b, .w, .l, .q] addr1 addr2 count |
| 12 | |
| 13 | Description |
| 14 | ----------- |
| 15 | |
| 16 | The cmp command is used to compare two memory areas. By default it works on |
| 17 | four byte tuples. By appending .b, .w, .l, .q the size of the tuples is |
| 18 | controlled: |
| 19 | |
| 20 | cmp.b |
| 21 | compare 1 byte tuples |
| 22 | |
| 23 | cmp.w |
| 24 | compare 2 byte tuples |
| 25 | |
| 26 | cmp.l |
| 27 | compare 4 byte tuples |
| 28 | |
| 29 | cmp.q |
| 30 | compare 8 byte tuples |
| 31 | |
| 32 | The parameters are used as follows: |
| 33 | |
| 34 | addr1 |
| 35 | Address of the first memory area. |
| 36 | |
| 37 | addr2 |
| 38 | Address of the second memory area. |
| 39 | |
| 40 | count |
| 41 | Number of bytes to compare (as hexadecimal number). |
| 42 | |
| 43 | Example |
| 44 | ------- |
| 45 | |
| 46 | In the example below the strings "Hello world\n" and "Hello World\n" are written |
| 47 | to 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 | |
| 95 | Configuration |
| 96 | ------------- |
| 97 | |
| 98 | The cmp command is only available if CONFIG_CMD_MEMORY=y. The cmp.q command is |
| 99 | only available if additionally CONFIG_MEM_SUPPORT_64BIT_DATA=y. |
| 100 | |
| 101 | Return value |
| 102 | ------------ |
| 103 | |
| 104 | The return value $? is true (0) if the compared memory areas are equal. |
| 105 | The reutrn value is false (1) if the compared memory areas differ. |