The LazyBoy Library Manual - StrToWord

Part of the Strings group.

%imacro StrToWord 2-3
Prefers: AX, ES:DI
Prefers: AX, DI

Convert an ASCIIZ string to a 16-bit unsigned integer. The ASCIIZ can be a string representing a positive integer, hexadecimal or binary number.

A hexadecimal and binary numbers are caseless. A hex number starts with either 0x or simply x.

A binary number contains only 0 and 1 followed by a single b character.

If the value is negative, contains invalid characters or requires more than a word, the Carry flag will be set to indicate the string could not be converted.

%2 is a pointer. If no segment is provided for %2, then ES is assumed. Unless %2 is a code label, then CS will be assumed.

If %3 is SIGNED or SINT, then the output will be a signed 16-bit integer and a ASCIIZ string that represents a negative number will be permitted. However the negative symbol is forbidden for strings using hexadecimal or binary representations. For those, the high bit will indicate a negative value. For example, 0x7fff will be 32767 and 0x8000 will be -32768.

Examples:

    StrToWord  ax, di         ; convert string at es:di to an unsigned integer.
    StrToWord  ax, ASTR       ; convert string at cs:ASTR to an unsigned integer.
    StrToWord  ax, bx, sint   ; convert string at es:bx to an signed integer.