Indirect addressing DM in CX-Programmer

Updated March 18, 2025

Indirect Addressing in CX-Programmer: *D vs. @D

In CX-Programmer, indirect addressing allows accessing data dynamically using an address stored in another memory location. The *D and @D operators determine how the address is interpreted.


1. Key Difference Between *D and @D

Operator Address Format Explanation
*D BCD (Binary-Coded Decimal) The value in the pointer register is treated as a BCD number, meaning it can only store values 0-9999.
@D Binary The value in the pointer register is treated as a binary number, allowing full 16-bit addressing (0-65535).

2. Using *D (BCD Indirect Addressing)

*D treats the pointer value as BCD, meaning only valid BCD values (0–9999) can be used. If a non-BCD value is in the pointer, it may cause errors.

Example: Indirect MOV Using *D

If:

  • D0 contains #0200 (BCD format, meaning 200 decimal).
  • D200 holds #1234.

Then:

MOV *D0 D10

What Happens?

  • D0 contains #200 (BCD).
  • *D0 means access D200.
  • The value in D200 (#1234) is moved to D10.

Correct Usage: D0 contains a valid BCD address (e.g., #0200).
Incorrect Usage Example: If D0 contains 021A, this is not a valid BCD value because A is not a decimal digit. This would cause an error or unexpected behavior.


3. Using @D (Binary Indirect Addressing)

@D treats the pointer as a binary value, allowing a full range of addresses (0–65535). This is generally more flexible and avoids BCD limitations.

Example: Indirect MOV Using @D

If:

  • D0 contains &200 (binary).
  • D200 holds &5678.

Then:

MOV @D0 D20

What Happens?

  • D0 contains &200 (binary).
  • @D0 means access D200.
  • The value in D200 (&5678) is moved to D20.

Advantage: @D allows full 16-bit addressing, unlike *D which is limited to BCD.
More Common Use Case: Most PLC programmers prefer @D for flexibility.


4. When to Use *D vs. @D

Operator Use Case
*D (BCD Indirect) When working with BCD-encoded data (legacy systems, HMI settings, etc.).
@D (Binary Indirect) When working with normal binary memory addressing (recommended in most cases).

5. Summary

  • *D is for BCD-formatted addresses (0-9999), which may cause errors if non-BCD values are used.
  • @D is for binary-formatted addresses (0-65535) and is generally more versatile.

Recommendation

Unless working with BCD-encoded data, @D is preferred because it avoids BCD conversion issues.

 

 

Start a Conversation
This conversation is closed
Uploading...