186 CALL transfer control to a machine code subroutine Purpose This statement makes the computer execute a piece of machine code which the user has previously placed in the computer’s memory. Before using this powerful statement you should have a good understanding of machine code and assembly language as incorrect use can destroy a program completely! Unfortunately there is not enough room in this book to teach assembly language programming but brief guidance on the principles of 6502 assembly language is given in chapter 44. Examples 50 rotate=&0270 60 CALL rotate,J,K,L 200 CALL 1234,A$,M,J$ A statement to call a piece of machine code.
The number of parameters passed is variable and may be zero. The parameters are variable parameters and may be changed on execution of the subroutine. The addresses of parameters are passed in a parameter block starting at location 0600 hex. Description On entry to the subroutine the processor’s A, X, Y registers are initialised to the least significant bytes of the integer variables A%, X% and Y%. The carry flag is set to the least significant bit of the C% variable. On entry a parameter block is set up by the computer and it contains the following list:
Number of parameters 1 byte Parameter address 2 bytes Parameter type 1 byte Parameter address Parameter type Repeated as often as necessary Parameter types 0 - 8 bit byte (eg ?X) 4 - 32 bit integer variable (eg !X or X%) 5 - 40 bit floating point number (eg V) 128 - A string at a defined address (eg $X - terminated by a &0D) 129 - A string variable such as A$