# 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.&#x20;

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)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hyperdbg.org/commands/scripting-language/functions/memory/memcmp.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
