> For the complete documentation index, see [llms.txt](https://docs.hyperdbg.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hyperdbg.org/commands/scripting-language/functions/memory/memcmp.md).

# memcmp

### Function

> memcmp

### Syntax

> memcmp( Ptr1, Ptr2, Num );

### Parameters

**\[Ptr1]**

A [MASM-like expression](https://docs.hyperdbg.org/commands/scripting-language/assumptions-and-evaluations) or a string to compare with **Ptr2**.

**\[Ptr2]**

A [MASM-like expression](https://docs.hyperdbg.org/commands/scripting-language/assumptions-and-evaluations) or a string to compare with **Ptr1**.

**\[Num]**

Number of bytes to compare.

### Description

Compares the first ***Num*** bytes of the block of memory pointed by ***Ptr1*** to the first *num* bytes pointed by ***Ptr2**.*

### Return value

Returns an integer value indicating the relationship between the content of the memory blocks:

| return value | indicates                                                                                                                                                   |
| ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <0           | The first byte that does not match in both memory blocks has a lower value in ***Ptr1*** than in ***Ptr2*** (if evaluated as ***unsigned char*** values).   |
| 0            | The contents of both memory blocks are equal.                                                                                                               |
| >0           | The first byte that does not match in both memory blocks has a greater value in ***Ptr1*** than in ***Ptr2*** (if evaluated as ***unsigned char*** values). |

### Examples

``memcmp(fffff806`6de00000, @rax+c0, 5);``

Compare the first **5** bytes of the memory located at ``fffff806`6de00000`` with the memory located at `@rax+c0`.

`memcmp(@rcx, "Test1", 5);`

Compare the first 5 bytes of the memory located at `@rcx` with the string `"Test1"`.

### Remarks

This function checks for the validity of both the source and the destination address before the comparison.

The support for this function is added from **v0.7**.

### Related

[strcmp](https://docs.hyperdbg.org/commands/scripting-language/functions/strings/strcmp)

[wcscmp](https://docs.hyperdbg.org/commands/scripting-language/functions/strings/wcscmp)
