iiGetHex bb#,nn [D>=28]
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:
- Typically used for receiving ASCII-coded information from an Xwire peripheral board.
- Conversion will end on the first unexpected character or after 2 hexadecimal digits.
Dialect exclusions: Not available in dialects before 28
See also: iifPrintWFW, iifPrintWVW,
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).:
- Launch SPLat/PC.
- Set the dialect to 28 (
File>Configure>Dialect). If you don’t have you will need to upgrade SPLat/PC. - Copy the code below into the edit window.
- Display the registers (type
CTRL+R) - Set a breakpoint on the last line (position the cursor and press
F9) - Reset everything by typing
CTRL+F7. - Press
F5repeatedly, and look at the result in X, I and R each time. - Type
CTRL+F7at 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