Last Modified: 1/2/2021
Sets the declaration of a user defined routine.
Name | Type | Required | Description |
RoutineType | System Identifier | Yes | Tells the compiler what kind of routine you're creating. |
RoutineName | Text | Yes | The name of your routine. |
ParameterList | Any | No | Define any parameters that will be used in the routine. |
Type | System Identifier | No | This is only for non-asm functions. If omitted, the compiler will assign a data type based upon the routines suffix. |
Type | Details |
Function | Functions perform actions that return a value. |
Sub | Subroutines perform actions that don't return a value. |
Asm Function | Similar to a regular Function, this type uses M68K assembly as the source code and uses registers instead of variables for parameters. |
Asm Sub | Similar to a regular Sub, this type uses M68K assembly as the source code and uses registers instead of variables for parameters. |
Syntax: Declare <RoutineType> <RoutineName> ([<ParameterList>]) [As <Type>] |
MySub 10, 10 Print MyFunc(12,12) Print MyASMFunc(5,1) ' Example Sub Declare Sub MySub(x As Integer, y As Integer) Print x * y End Sub ' Example Function Declare Function MyFunc(x As Integer, y As Integer) As Integer Return x * y End Function ' ASM Example Function Declare Asm Function MyASMFunc(d0.l, d1 As Byte) add.l d1, d0 End Function |
If you're defining an asm routine, the ParemeterList is assembly registers. You can use d0, d1, d2, d3, d4, d5, d6, and d7 for data registers, and a0, a1, a2, a3, a4, a5, a6, a7 for address registers. You will need to specify the data type for the registers:
Type | Details |
As Byte | Let's the compiler know the register is expected to hold Byte sized data. |
As Integer | Let's the compiler know the register is expected to hold Integer (2 bytes) sized data. |
As Long | Let's the compiler know the register is expected to hold Long (4 bytes) sized data. |
As String | Let's the compiler know the register is expected to hold String sized data. This is only valid for address registers. |
Data registers can be shorted with .{X}, where {X} = b for Byte, w for Word (Integer), and .l for Long.