Register Indirect Addressing Mode

The offset must be constant for the register indirect addressing modes. This constant may be an immediate or a variable address relocated by the linker.

Example:

  STA   @Variable_Name,X

  

The following simple example illustrates the use of the HLI Assembler:

Assuming that str points to a character array, you can write a simple function in assembly language to determine the length of a string:

Listing: strlen() Definition
int strlen (char *str)
  /*** The 'str' character array is passed on the stack. strlen returns 
      length of 'str'.

      This procedure assumes len(str) is smaller than 256! */

{

  __asm {

    LDHX str       ; load pointer

    CLRA           ; init counter

    BRA test       ; go to test

  loop:

    AIX   #1       ; increment pointer

    INCA           ; increment counter

  test:

    TST   0,X      ; not end of string?

    BNE   loop     ; next char

    CLRX           ; return value in X:A(see later)

  };

  /* C statements could follow here */

}
Note: Unless #pragma NO_ENTRY is set, the Compiler takes care of entry and exit code. You do not have to worry about setting up a stack frame.