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