> 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)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
