View Javadoc

1   package com.tapina.robe.swi.clib.string;
2   
3   import com.tapina.robe.runtime.Environment;
4   import com.tapina.robe.swi.clib.Stub;
5   
6   /***
7    * This function searches for a2 (converted to an unsigned char) in the string pointed to by a1 (including null
8    * terminator).
9    * Returns: Pointer to the found character, or a null pointer if not found.
10   */
11  public class StrChr extends Stub {
12      public void executeStub(Environment environment) {
13          final int[] R = environment.getCpu().R;
14          final int pos = environment.getMemoryMap().getString0(R[0]).indexOf(R[1]);
15          R[0] = (pos != -1)? R[0] + pos : 0; 
16      }
17  }