cmp.rst 2.5 KB

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