Amos Professional Manual  Contents  Index

Machine Code


Note that AREG(3) to AREG(6) will not be transferred to the routine. These registers cannot be changed, as they are used to store important system information. To return values to AMOS Professional Basic, AREG and DREG can be used to read the contents of the Address and Data registers, after the procedure has been called.

The second alternative method is much neater. Values are entered using normal parameters. As usual, a list of parameters is specified as part of the procedure definition, like this:

X> Rem Use no parameters but take info directly from AREG and DREG values
   Procedure _MACHINE°
   Procedure _MACHINE1[A] : Rem Enter one integer into procedure
   Procedure _MACH1NE2[A,B,C$] : Rem Get two integers and one string

The values of the parameters are pushed onto the Parameter stack, pointed to by A3. These parameters are stored in reverse order, and are four bytes in length.

_MACHINE1 will grab the parameters like this:

Move.l (a3)+,d0

_MACHINE2 will grab the parameters as follows:

; Grab the string. Each string is stored at an EVEN address,
; starting with the length of the string, and then the string itself

Move.l (a3)+,a2             * Address of the string
Move.w (a2)+,d2             * Length of the string

; A2 now points to the first character

; Grab the two integers

Move.l (a3)+,d1             * Grab "B"
Move.l (a3)+,d0             * Grab "A"

The AMOS Professional stack works in the same way as a conventional stack, so although anything below can be changed, do not touch any values above the base address contained in A3. Also note that the space available for the routine depends on the level of the procedure, so if it is called from the main program approximately 3k is available. This can be increased by a call to the SET STACK command from AMOS Professional Basic.

To return values to AMOS Professional Basic, the value of DO is available from the PARAM function automatically.

Calling machine code from an address or bank
There is another option for calling machine code directly from a memory bank or an address.

Back    Next
14.A.13