Heinrich Schuchardt | 50cd4ce | 2022-11-13 13:27:32 +0100 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+: |
| 2 | |
Heinrich Schuchardt | 1b0c316 | 2024-01-14 14:53:13 +0100 | [diff] [blame] | 3 | .. index:: |
| 4 | single: cmp (command) |
| 5 | |
Heinrich Schuchardt | 50cd4ce | 2022-11-13 13:27:32 +0100 | [diff] [blame] | 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 |
Heinrich Schuchardt | 8527b02 | 2022-11-17 13:42:04 +0100 | [diff] [blame] | 20 | four byte (32-bit) values. By appending .b, .w, .l, .q the size of the |
| 21 | values is controlled: |
Heinrich Schuchardt | 50cd4ce | 2022-11-13 13:27:32 +0100 | [diff] [blame] | 22 | |
| 23 | cmp.b |
Heinrich Schuchardt | 8527b02 | 2022-11-17 13:42:04 +0100 | [diff] [blame] | 24 | compare 1 byte (8-bit) values |
Heinrich Schuchardt | 50cd4ce | 2022-11-13 13:27:32 +0100 | [diff] [blame] | 25 | |
| 26 | cmp.w |
Heinrich Schuchardt | 8527b02 | 2022-11-17 13:42:04 +0100 | [diff] [blame] | 27 | compare 2 byte (16-bit) values |
Heinrich Schuchardt | 50cd4ce | 2022-11-13 13:27:32 +0100 | [diff] [blame] | 28 | |
| 29 | cmp.l |
Heinrich Schuchardt | 8527b02 | 2022-11-17 13:42:04 +0100 | [diff] [blame] | 30 | compare 4 byte (32-bit) values |
Heinrich Schuchardt | 50cd4ce | 2022-11-13 13:27:32 +0100 | [diff] [blame] | 31 | |
| 32 | cmp.q |
Heinrich Schuchardt | 8527b02 | 2022-11-17 13:42:04 +0100 | [diff] [blame] | 33 | compare 8 byte (64-bit) values |
Heinrich Schuchardt | 50cd4ce | 2022-11-13 13:27:32 +0100 | [diff] [blame] | 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 |
Rasmus Villemoes | dd5b958 | 2024-01-03 11:47:10 +0100 | [diff] [blame] | 102 | only available on 64-bit targets. |
Heinrich Schuchardt | 50cd4ce | 2022-11-13 13:27:32 +0100 | [diff] [blame] | 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. |