[Return to top]

Enhanced BASIC74 language reference by Lee Davison
[Back]


Introduction

Most of EhBASIC74 is identical in operation to 6502 EhBASIC so this page will just describe the keywords that differ from that version. Code that doesn't use the features of one version should run identically on the other.
BASIC Keywords
Here is a list of BASIC keywords that differ from the 6502 version of EhBASIC. They are only valid when entered in upper case as shown and spaces may not be included in them. So, for example, TIMER1 is valid but TIMER 1 is not.

A2D CLEAR CNTR0 CNTR1 COUNT D2A1
D2A2 EVENT INT0 INT1 INT2 INT3
INT4 IRQ NMI ON OFF PRES12
PRESX PRESY PULSE PWM RETIRQ RETNMI
RETURN START STOP TIMER TIMER1 TIMER2
TIMERX TIMERY + -
varis a valid variable name
var$is a valid string variable name
var()is a valid array name
var$()is a valid string array name
 
expressionis any expression returning a result
expression$   is any expression returning a string result
 
addris an unsigned integer in the range +/- 16777215 that will be wrapped to the range 0 to 65535
bis a byte value 0 to 255
nis an integer in the range 0 to 63999
wis an integer in the range -32768 to 32767
iis a +ve integer value
ris real number
+ris a +ve value real number (0 is considered +ve)
$is a string literal

BASIC74 Commands

INTx {ON|OFF|CLEAR}
Changes INTx event handling (where x is one of 0, 1, 2, 3 or 4).

ON

Enables the INTx handling subroutine after it has been turned off.

Note If a INTx event occured while the INTx event handling was disabled then it will be actioned immediately after this command.

OFF
Disables the INTx handling subroutine but does not remove the assignment. INTx events that occur while the handler is disabled will still be flagged for action.
CLEAR
Cleares the INTx handling assignment. After an INTx CLEAR the handling subroutine can only be restarted with an ON INTx command.
INTx {+|-}
Sets the detection edge for INTx (where x is one of 0, 1, 2, 3 or 4). + sets a low to high transition (positive edge) as the trigger, - sets a high to low (negative edge) as the trigger. The default is -. Note that changing the trigger edge when the interrupt is enabled may cause the interrupt to trigger.
CNTRx {ON|OFF|CLEAR}
Changes CNTRx event handling (where x is either 0 or 1).

ON

Enables the CNTRx handling subroutine after it has been turned off.

Note If a CNTRx event occured while the CNTRx event handling was disabled then it will be actioned immediately after this command.

OFF
Disables the CNTRx handling subroutine but does not remove the assignment. INTx events that occur while the handler is disabled will still be flagged for action.
CLEAR
Cleares the CNTRx handling assignment. After a CNTRx CLEAR the handling subroutine can only be restarted with an ON CNTRx command.
CNTRx {+|-}
Sets the detection edge for CNTRx (where x is one of 0 or 1). + sets a low to high transition (positive edge) as the trigger, - sets a high to low (negative edge) as the trigger. The default is -. Note that changing the trigger edge when the interrupt is enabled may cause the interrupt to trigger.
PRESq <b>
Sets the value for prescaller q (where q is one of 12, X or Y).
TIMERp {TIMER|PWM|COUNT|PULSE}
Sets TIMERp timing mode (where p is either X or Y).

TIMER

The timer (X or Y) counts down (f/16)/(1+PRESq)/(1+TIMERp).
PWM
If the corresponding active edge selection bit (CNTR0 for timer X, CNTR1 for timer Y) is "0" (CNTRx -) then the counter counts as in timer mode while the pin is at "1". If the corresponding active edge selection bit (CNTR0 for timer X, CNTR1 for timer Y) is "1" (CNTRx +) then the counter counts as in timer mode while the pin is at "0". The Prescaller and timer latches are preset to $FF by setting this mode and when the selected event (-ve or +ve edge) happens the prescaller and timer values are copied and available to BASIC using the TIMERp (where p is either X or Y) function.
COUNT
The same as timer mode except pulses on the corresponding counter pin (CNTR0 for timer X, CNTR1 for timer Y) are counted. Selecting this mode also sets the corresponding pin to input mode.
PULSE
As timer mode except when the timer reaches $0000 the counter pin (CNTR0 for timer X, CNTR1 for timer Y) is inverted. Selecting this mode also sets the corresponding pin to output mode.
TIMERp {START|STOP}
Enables or disables counting for TIMERp (where p is either X or Y).
TIMERq {ON|OFF|CLEAR}
Changes TIMERq event handling (where q is one of 1, 2, X or Y).

ON

Enables the TIMERq handling subroutine after it has been turned off.

Note If a TIMERq event occured while the TIMERq event handling was disabled then it will be actioned immediately after this command.

OFF
Disables the TIMERq handling subroutine but does not remove the assignment. TIMERq events that occur while the handler is disabled will still be flagged for action.
CLEAR
Cleares the TIMERq handling assignment. After a TIMERq CLEAR the handling subroutine can only be restarted with an ON TIMERq command.
TIMERq <b>
Sets the value of TIMERq (where q is one of 1, 2, X or Y).
RETIRQ
This command has been removed from EhBASIC74. It's function is now handled by an enhanced RETURN command.
RETNMI
This command has been removed from EhBASIC74. It's function is now handled by an enhanced RETURN command.
RETURN
As well as returning program execution to the next statement after the last GOSUB in EhBASIC74 RETURN also restores execution to the next statement after event subroutine has been executed. RETURN checks the type of event and automatically restores the enabled flag for the interrupt that caused the event.
ON
See INTx {ON|OFF|CLEAR}, CNTRx {ON|OFF|CLEAR} or TIMERq {ON|OFF|CLEAR}.
OFF
See INTx {ON|OFF|CLEAR}, CNTRx {ON|OFF|CLEAR} or TIMERq {ON|OFF|CLEAR}.
CLEAR
See INTx {ON|OFF|CLEAR}, CNTRx {ON|OFF|CLEAR} or TIMERq {ON|OFF|CLEAR}.
ON {IRQ|NMI} <n>
These commands have been removed from EhBASIC74 as there is no IRQ or NMI interrupt on the 740 series microprocessor.
ON INTx <n>
Set up the INTx routine pointers (where x is one of 0, 1, 2, 3 or 4). This sets up the effective GOSUB line that is taken when an interrupt happens. When the effective GOSUB is taken the interrupt, INTx, is turned off. The interrupt is turned back on when normal program flow is resumed by a matched RETURN command.
ON CNTRx <n>
Set up the CNTRx routine pointers (where x is one of 0 or 1). This sets up the effective GOSUB line that is taken when a counter interrupt happens. When the effective GOSUB is taken the interrupt, CNTRx, is turned off. The interrupt is turned back on when normal program flow is resumed by a matched RETURN command.
ON TIMERq <n>
Set up the TIMERq routine pointers (where q is one of 1, 2, X or Y). This sets up the effective GOSUB line that is taken when a timer interrupt happens. When the effective GOSUB is taken the interrupt, TIMERq, is turned off. The interrupt is turned back on when normal program flow is resumed by a RETURN command.
IRQ {ON|OFF|CLEAR}
This command has been removed from EhBASIC74 as there is no IRQ interrupt on the 740 series microprocessor.
NMI {ON|OFF|CLEAR}
This command has been removed from EhBASIC74 as there is no NMI interrupt on the 740 series microprocessor.
D2Ax <b>
Output byte b as an analog voltage on D-A port x (where x is 1 or 2). Setting either convertor also sets the corresponding pin to analog output mode.
D2Ax {ON|OFF}
Enables or disables the D2Ax output (where x is one of 0 or 1).
+
See INTx {+|-} or CNTRx {+|-}.
-
See INTx {+|-} or CNTRx {+|-}.
BASIC74 Functions
Functions always return a value, be it numeric or string, so are used on the right hand side of the = sign or in commands requiring an expression e.g. after PRINT, within expressions, or in other functions.

A2D(<b>)

Returns the value of the A-D convertor input b, where b is 0 to 7. Any value for b outside this range will cause a function call error.

EVENT

Returns a boolean value. If any enabled interrupt has occured since EVENT was last examined then EVENT will return -1 else EVENT will return 0
TIMERp
Returns the count value from TIMERp (where p is either X or Y). As this is a count down timer the value returned is first subtracted from zero then returned as if it had been DEEKed from the timer registers. This function is only of any use when TIMERp is being used in PWM mode.

e-mail me [e-mail]
Last page update: 4th June, 2003.