OS_Convert of long longs
Sprow (202) 1155 posts |
There are some SWI numbers allocated (and appear in the name <=> number table) but that aren’t implemented that I want to use. Before implementing them, any idea how best to pass in the 64 bit number? Pass it in R3, or use R0 as a pointer to a block of 2 words (a la DiscOp64). Infact, since they’ve never been implemented could they be changed to OS_ConvertThingN where N is passed in a register rather than proliferating SWI numbers – there aren’t that many left below &100. |
Jeffrey Lee (213) 6048 posts |
That sounds fine to me. If you went with that approach, it would also make sense to use a buffer to store the result rather than registers (since the algorithm might end up being used for very large ‘N’ values) |
Steve Revill (20) 1361 posts |
Seconded on Jeffrey’s suggestion. Clearly, it would need to return with suitable X-bit-set errors for various problem cases (presumably the only one likely is insufficient space in the supplied buffer). Maybe there’d be a mode where you pass in zero and zero as the buffer pointer and size in order to request the estimated buffer requirements? |
Sprow (202) 1155 posts |
Well if we’re all pretty relaxed about deviating from the spirit of the existing OS_Convert family I’m tempted to ditch the currently reserved block and just go with a single SWI. This would free up SWIs &EE-&F4 and just use &ED. SWI OS_ConvertNBytesOfInputStuffToSomeOtherStuff (or more catchy name) on exit If R2 is -ve on entry, R2 returns minus the space needed for conversion (like OS_ReadVarVal). |
Jeffrey Lee (213) 6048 posts |
I did get a bit confused between OS_ConvertXXX and OS_ReadXXX there. What I meant to say was, to use a buffer for the input number, so the SWI can be extended to cope with numbers larger than 2^64 should the need arise (Edit – Although it looks like everyone’s managed to work out what I meant anyway). Steve’s idea about allowing the required destination buffer size to be read makes sense as well. |
Steve Revill (20) 1361 posts |
I suppose this API will need to define the possible error codes, of which I can foresee maybe three:
|
Sprow (202) 1155 posts |
Sounds like a plan. Need a competition for the name: OS_ConvertMultipleN is all I can come up with (vaguely fitting the OS_ConvertCardinal4 pattern). Or OS_ConvertVariedVaried… |
Dave Higton (281) 668 posts |
How about the simplest possible: OS_Convert? |
Steve Revill (20) 1361 posts |
OS_GenericConvert |
Sprow (202) 1155 posts |
So I’ve come up with
Have I missed anything obvious? I’m conciously not trying to just make it like printf(), but thinking what common integer conversions modules frequently need to do to present numbers to humans. |
Trevor Johnson (329) 1645 posts |
Or a space. |
Sprow (202) 1155 posts |
Well, yes, whatever the Territory Manager says would be used. |