
U-Boot Commands
LITE5200B User’s Manual, Rev. 0
7-8
Freescale Semiconductor
7.7
CMP
cmp
– Memory compare.
cmp [.b, .w, .l] addr1 addr2 (count)
The
cmp
command tests of the contents of two memory areas and determines whether or not the contents
of the two memory areas are identical or not. The command will either test the whole area as specified by
the 3rd (count) argument or stop at the first difference if the count argument is not specified.
The following example demonstrates comparing the memory ranges 0x100000 – 0x10002F to 0x400000
– 0x40002F. The contents of the two memory ranges are shown below.
00100000: 27051956 50ff4342 6f6f7420 312e312e '..VP.CBoot 1.1.
00100010: 3520284d 61722032 31203230 3032202d 5 (Mar 21 2002 -
00100020: 2031393a 35353a30 34290000 00000000 19:55:04)......
40000000: 27051956 50504342 6f6f7420 312e312e '..VPPCBoot 1.1.
40000010: 3520284d 61722032 31203230 3032202d 5 (Mar 21 2002 -
40000020: 2031393a 35353a30 34290000 00000000 19:55:04)......
=> cmp 100000 40000000 400
word at 0x00100004 (0x50ff4342) != word at 0x40000004 (0x50504342)
Total of 1 word were the same
=>
Like most memory commands, the
cmp
command accesses the memory in different sizes: 32 bit (long
word), 16 bit (word) or 8 bit (byte) data. If invoked just as
cmp,
the default size (32 bit or long words) is
used; the same can be selected explicitely by typing
cmp.l
instead. To access memory as 16 bit (word
data), use the variant
cmp.w
; to access memory as 8 bit (byte data) use
cmp.b
. Please note that the count
argument specifies the number of data items to process, i.e., the number of long words or words or bytes
to compare.