On 31/01/13 18:50, Norman Dunbar wrote:
On 31/01/13 17:31, Ian Burkinshaw wrote:

For example I have never realy understood which registers are used for
what.
They can be used for anything. However, calling QDOSMSQ routines via
vectors or traps does mean that you have to have certain "things" in
certain registers.

To close a file, for example, you do this:

         moveq #io_close,d0     Close file trap code
         trap #2                Do it

Trap #2 is the call into QDOSMSQ.

Io_close is the value 2 and must be in D0 to tell the trap #2 what
operation to carry out.

The channel to be closed is in register A0.L (Not shown here).

So, with those three registers set up, you execute the trap, and
whatever channel id was in A0.L will be closed.

On return, D0 contains any potential error codes, or zero for no errors.

As far as your own assembly programs are concerned, you have free reign
to use the registers as you wish, subject to whatever rules for register
usage are in force when running CALLed code or EXEC'd code.


Also managing the stack is not clear to me either. But to be fair
I have not studied it that closely.

The stack is register A7. Also known as SP. To push a value onto the
stack, say register D0.L then you would:

         move.l d0,-(a7)

Which simply says, subtract the size of a long word from A7, then store
the long value in D0 at the address that A7 now holds.

To pop a value back off the stack, do the opposite:

         move.l (a7)+,d0

Which says, copy the long value from the address that A7 holds, into D0,
then add the size of a long to A7.

Ok, I'll get off my soap box! ;-)

Cheers,
Norm.

Hi Norman,

Your articles were one the high points.

I want more assembley language articles and Qptr

Derek
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm

Reply via email to