Page 1 of 1
Using the Arithmetic Stack from a job, not S*BASIC
Posted: Mon Dec 13, 2021 4:57 pm
by NormanDunbar
My mind has gone on this matter, and I'm unable to find anything helpful in either the old QDOS manuals, Pennel, Dickins etc, or the new SMSQ/E Manual from Wolfgang.
I'm writing a task for the next edition of the eMagazine, and I need to be able to use the maths stack and arithmetic package to do various things. For the life of me I can't remember if (a) this is permitted and (b) how the hell to do it!
If anyone can give me a prod in the right direction, I'd be grateful. I'm looking to convert a string of ASCII digits to an value on the maths stack using CN_DTOF (QDOS) aka CV.DECFP (SMSQ).
Entry:
D7.L = pointer 1 past the end of the (input) buffer (relative A6)
A0.L = pointer to the input buffer (relative A6)
A1.L = Pointer to maths stack (relative A6)
And, is it ok to grab the current maths stack pointer from BV_CHRIX (QDOS) ???? (SMSQ) as I would normally do in a SuperBASIC extension?
I
need a drink!

(Or maybe
that's the problem!)
Cheers,
Norm.
Re: Using the Arithmetic Stack from a job, not S*BASIC
Posted: Mon Dec 13, 2021 5:08 pm
by mk79
Just provide your own stack with enough space and make that relative to A6 (whether subtracting A6 from A1 or setting A6 to 0 is your choice). DON‘T grab the Basic stack, it‘s not yours to use!
Re: Using the Arithmetic Stack from a job, not S*BASIC
Posted: Mon Dec 13, 2021 5:33 pm
by NormanDunbar
Interesting, that's what I would have done. I did it before in QL Today when I "created" something along these lines, but got a right telling off from George Gwilt, and others, about using my own space for the maths stack!
Unfortunately, the SMSQ/E manual doesn't go into much detail about how much space is required for "working out". It's fine for telling me how much the stack pointer will change for each operation. Never mind, this is exactly what trial an error is all about! EDIT: The SMSQ manual mentions 30 bytes required, my mistake.
Many thanks.
Cheers,
Norm.
Re: Using the Arithmetic Stack from a job, not S*BASIC
Posted: Mon Dec 13, 2021 6:53 pm
by tofro
Norman,
Note some routines (graphics, for example, that take their parameters from the RI stack) may use a lot more than the mentioned 30 bytes (The manual says 240).
And even if it might look tempting, no, QA.RESRI cannot be used to allocate space on your private RI stack. Use standard memory allocation routines, make sure you allocate an even amount and let a1,a6 point to the top of the allocated area (I normally use a1 to point to the base and have a6 hold the length - or vice versa, that makes it easy to check for overflow) - And leave the S*BASIC variables that point to "the" a1,a6 stack alone.
Re: Using the Arithmetic Stack from a job, not S*BASIC
Posted: Mon Dec 13, 2021 7:11 pm
by NormanDunbar
Thanks ToFro.
I don't "do" graphics, so no problems there. And yes, I'll not be using space allocation routines. I'll probably end up using some of the job's data space.
Appreciate the responses from both of you, thanks.
Cheers,
Norm.
Re: Using the Arithmetic Stack from a job, not S*BASIC
Posted: Wed Dec 15, 2021 11:08 am
by NormanDunbar
And after all that, it turns out that the routine I
thought was there, isn't! I was looking to print a signed long integer and needed to convert it to ASCII for printing. Turns out that while I can do this with word integers and floats, I can't do it easily, with a vector, for long words. Of course, I can stack the long integer as a float and print that, I suppose, but then again, there's a difference between QDOS and SMSQ where the latter has an easy method of converting the long integer on TOS into a float, QDOS needs the old fashioned manual conversion routine. Sigh!
I wonder why there was never a long integer printing vector in QDOS and why it remains "missing" in SMSQ? Seems a little strange given the amount of long words flying around the system. I suspect it was "easier" to convert to a float and print that.
C'est la vie, as they say in Wales!
Cheers,
Norm.
PS. I already have a "print long integer" routine from a past life that I can use, but I was hoping for a simple life!
Re: Using the Arithmetic Stack from a job, not S*BASIC
Posted: Wed Dec 15, 2021 12:16 pm
by mk79
NormanDunbar wrote:I wonder why there was never a long integer printing vector in QDOS and why it remains "missing" in SMSQ?
Pure speculation, but SuperBasic never had a real concept of long integers, so the routine wasn't needed. Also, there is no full 32-bit divide function in the 68008, so the word-to-ascii function would be bigger and slower without a good reason (binary and hex, which do exist in long forms, more or less only need different loop counters). SMSQ/E on the other hand has a real 32-bit to ASCII function and it only sign extends any 16-bit calls. It's not vectorized however, maybe because there is no good place to put it.
Marcel
Re: Using the Arithmetic Stack from a job, not S*BASIC
Posted: Wed Dec 15, 2021 12:30 pm
by dilwyn
NormanDunbar wrote:
C'est la vie, as they say in Wales!
??
Sorry, I don't speak Leeds Scottish....
Re: Using the Arithmetic Stack from a job, not S*BASIC
Posted: Wed Dec 15, 2021 1:53 pm
by NormanDunbar
mk79 wrote:Pure speculation, but SuperBasic never had a real concept of long integers,.......
Thanks Marcel, that makes more sense than my suspicions. Shame there's nowhere to put the "vector" in SMSQ, it would be handy. I doubt there's an easy way to (a) find it and (b) call it without much messing around?
Dilwyn wrote:???
Sorry Dilwyn, everyone else says "... as they say in France", I just changed it to Wales to see if anyone was listening. Nobody yet, until now, has mentioned it. Well spotted!
Cheers,
Norm.