Search code examples
assemblypowerpc

Should summed effective addresses 'wrap' in PowerPC? If so, how?


For example, the PowerPC book I, section 3.3.2, defines the lbz instruction as:

Let the effective address (EA) be the sum (RA|0)+ D. The byte in storage addressed by EA is loaded into RT56:63. RT0:55 are set to 0.

What should I do in the following two situations?

  • Should I wrap or do something when (RA) + D > memory_capacity?
  • Should I wrap or do something when (RA) + D > 4294967295?

In other words, is the effective address just the sum of (RA) + D, or is the calculation done mod memory_capacity or mod 2^32-1?

Relevant practical material: every line that sets var EA in this script.


Solution

  • From the Power ISA 2.06 book, section 1.9.3 Effective Address Calculation

    In 32-bit mode, the low-order 32 bits of the 64-bit result, preceded by 32 0 bits, comprise the 64-bit effective address for the purpose of addressing storage. [...] As used to address storage, the effective address arithmetic appears to wrap around from the maximum address, 232-1, to address 0, except that if the current instruction is at effective address 232-4 the effective address of the next sequential instruction is undefined.