Showing changes from revision #4 to #5:
Added | Removed | Changed
Entry | |
---|---|
R0 | Base (2-36 Default 10) + 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 set1 |
R4 | “WIDE” API selector (see notes) |
Exit | |
---|---|
R0 | Preserved |
R1 | Pointer to terminator char |
R2 | Value converted |
R3 | Most significant word of value if bit 28 set1 else preserved |
R4 | Bitmask of R0 flags understood by current kernel1 else preserved |
1 Only applicable if “WIDE” API is in use.
The purpose of this call is to convert a string into an integer.
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.
In RISC OS 5.17 the SWI interface was expanded to allow reading of 64bit 64 bit numbers. In order to use this new interface, theSWI 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.