Knowledge Base

Extract (Get) a (8-bit) ASCII coded (printable) hexadecimal number from a buffer in RAM.

Consider an Xwire receive data block to be nn bytes of RAM starting at address bb. Extract a hexadecimal number from the data block, starting at RAM address bb+I (i.e. the starting address is indexed). Skip any leading spaces. Process at most 2 hexadecimal digits. Terminate on anything that’s not a hex digit. Advance I past the characters used, leaving it pointing at the terminating character (auto-index). Result in X, 0 if nothing there. R register signals outcome. 0 = OK, 1 = no valid hexadecimal number present. This instruction is not case sensitive.

Notes:

  1. Typically used for receiving ASCII-coded information from an Xwire peripheral board.
  2. Conversion will end on the first unexpected character or after 2 hexadecimal digits.

Dialect exclusions: Not available in dialects before 28

See also: iifPrintWFWiifPrintWVW,

Example

The following program will write some test data to RAM (iiPrintText) and then loop around extracting hexadecimal numbers from the data. To try the program yourself in SPLat/PC (simulation).:

  1. Launch SPLat/PC.
  2. Set the dialect to 28 (File>Configure>Dialect). If you don’t have you will need to upgrade SPLat/PC.
  3. Copy the code below into the edit window.
  4. Display the registers (type CTRL+R)
  5. Set a breakpoint on the last line (position the cursor and press F9)
  6. Reset everything by typing CTRL+F7.
  7. Press F5 repeatedly, and look at the result in X, I and R each time.
  8. Type CTRL+F7 at any time to start again.
XWBuffer        mEQU    100
BufLen          EQU     30

        LoadI   0
        iiPrintText      XWBuffer,"1 2    A   AB DEFedcba9876543210abcdef"
        ;                          012345678901234567890123456789

        LoadI   0
Agin:
        iiGetHex        XWBuffer,BufLen
        GoTo            Agin  ;<<<<<<  Breakpoint here