h6. [[OS SWI Calls]] h6(. » OS_ReadUnsigned h2. OS_ReadUnsigned h5. (SWI &21) |_<^{width:4em}. Entry | | |<^. R0 |<^. Base (2-36 Default 10) + [[OS_ReadUnsigned Flags|flags]] | |<^. R1 |<^. Pointer to string to convert | |<^. R2 |<^. Maximum value, if bit 29 set | |<^. R3 |<^. Most significant word of maximum value, if bits 28 & 29 set[1] | |<^. R4 |<^. "WIDE" API selector (see notes) | |_<^{width:4em}. Exit | | |<^. R0 |<^. Preserved | |<^. R1 |<^. Pointer to terminator char | |<^. R2 |<^. Value converted | |<^. R3 |<^. Most significant word of value if bit 28 set[1] else preserved | |<^. R4 |<^. Bitmask of R0 flags understood by current kernel[1] else preserved | fn1. Only applicable if "WIDE" API is in use. h4. Use The purpose of this call is to convert a string into an integer. h4. Notes If the string starts with &, base 16 is assumed. If the string starts with a decimal number followed by an underscore (e.g. '8_'), the base specified by the number is used. If no base is given in the string, the base in R0 is used, or 10 if that base is invalid (i.e. outside the range 2-36). Number conversion will terminate once the first non-number character is encountered. E.g. with the string "63fz", if the base was 10 then conversion would terminate once the 'f' is reached and a result of 63 would be returned. If the base was 16 then conversion would terminate once the 'z' is reached, with a result of 1599 (&63f), etc. h4. "WIDE" API In RISC OS 5.17 the SWI interface was expanded to allow reading of 64 bit numbers. In order to use this new interface, the SWI must be called with R4 set to &45444957 ("WIDE"). Note that in OS versions prior to 5.17, bits 0-28 of R0 are treated as the number base, while in 5.17 and above only bits 0-7 are treated as the number base. This means care must be taken when writing code that makes use of the new WIDE flags, as old OS versions may interpret the flags as part of the base, and then reset the base to the default value of 10 because the base number looks nonsensical. h4. See also * [[OS_ReadUnsigned Flags]]