# op\_offset

Convert operand to a complex offset expression This is a more powerful version of [op\_plain\_offset](/8.4/developer-guide/idc/idc-api-reference/alphabetical-list-of-idc-functions/697.md)() function. It allows to explicitly specify the reference type (off8, off16, etc) and the expression target with a possible target delta. The complex expressions are represented by IDA in the following form:

```
        target + tdelta - base
```

If the target is not present, then it will be calculated using target = operand\_value - tdelta + base The target must be present for LOW\.. and HIGH.. reference types ea - linear address of the instruction/data n - number of operand to convert (the same as in op\_plain\_offset) reftype - one of REF\_... constants target - an explicitly specified expression target. if you don't want to specify it, use -1. Please note that LOW\... and HIGH... reference type require the target. base - the offset base (a linear address) tdelta - a displacement from the target which will be displayed in the expression.

success op\_offset(long ea, int n, long reftype, long target, long base, long tdelta);

\#define REF\_OFF8 0 // 8bit full offset #define REF\_OFF16 1 // 16bit full offset #define REF\_OFF32 2 // 32bit full offset #define REF\_LOW8 3 // low 8bits of 16bit offset #define REF\_LOW16 4 // low 16bits of 32bit offset #define REF\_HIGH8 5 // high 8bits of 16bit offset #define REF\_HIGH16 6 // high 16bits of 32bit offset #define V695\_REF\_VHIGH 7 // obsolete #define V695\_REF\_VLOW 8 // obsolete #define REF\_OFF64 9 // 64bit full offset // note: processor modules or plugins may register additional // custom reference types (for example, REF\_HIGHA16 is // used by MIPS, SPARC, PPC, ALPHA, TRICORE, etc.) #define REFINFO\_RVA 0x10 // based reference (rva) #define REFINFO\_PASTEND 0x20 // reference past an item // it may point to an nonexistitng address // do not destroy alignment dirs #define REFINFO\_NOBASE 0x80 // offset base is a number // implies that base have be any value // nb: base xrefs are created only if base // points to the middle of a segment #define REFINFO\_SUBTRACT 0x0100 // the reference value is subtracted from // the base value instead of (as usual) // being added to it #define REFINFO\_SIGNEDOP 0x0200 // the operand value is sign-extended (only // supported for REF\_OFF8/16/32/64) #define REFINFO\_NO\_ZEROS 0x0400 ///< an opval of 0 will be considered invalid #define REFINFO\_NO\_ONES 0x0800 ///< an opval of \~0 will be considered invalid


---

# 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.hex-rays.com/8.4/developer-guide/idc/idc-api-reference/alphabetical-list-of-idc-functions/698.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.
