beautypg.com

Bp relative, Bp indexed, Indirect – Echelon Neuron User Manual

Page 43: Relative

background image

BP Relative

In the BP-relative addressing mode, the instruction argument is a general-

purpose register (R0 to R15). The register name is prefixed by an exclamation

mark (!) to indicate a displacement relative to the base page.
Example:

pop !R0 ; ( )

push !R2 ; ([R2], ...)

The pop !R0 instruction pops the value of TOS into the R0 register (byte 8 of the

base page). The push !R2 instruction pushes the contents of the R2 register

(byte 10 of the base page) into TOS.

BP Indexed

In the BP-indexed addressing mode, the instruction operand is TOS. The BP-

indexed addressing mode uses the value in TOS as an offset into the base page,

providing access to all 256 base-page bytes. The register name (TOS) is prefixed

by an exclamation mark (!) to indicate a displacement relative to the base page.
Because this addressing mode uses TOS for its operand, instructions that use

this addressing mode use NEXT for their argument.
Example:

pop !tos ; ( )

push !tos ; ([TOS], ...)

The pop !tos instruction pops the value of NEXT from the stack and places it

into the location within the base page specified by the value of TOS. The push

!tos instruction pushes the contents of the location within the base page,

specified by the value of TOS, into NEXT on the stack. That is, it pushes the

TOS-th byte of the base page into NEXT.

Indirect

In the indirect addressing mode, the instruction operand is the value that is at

the top of the return stack.
Example:

push [rsp] ; (z, ...)

The push [rsp] instruction pushes the contents of the top of the return stack

(pointed to by RSP) into TOS on the data stack. RSP is not changed.
Another instruction that uses the indirect addressing mode is the dbrnz

instruction, which uses this addressing mode for the branch destination. Its

reference to [RSP] is implied.

Relative

In the relative addressing mode, the instruction takes a relative address for its

operand; a distance rather than an absolute address (some instructions that use

relative addressing take a second operand). The branch destination is computed

by adding the relative address (the distance from the current IP) to the

Neuron Assembly Language Reference

33