Enhanced BASIC, language reference. by Lee Davison |
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 FLUSH INT0 INT1 INT2 INT3 INT4 IRQ NMI ON OFF PRES12 PRESX PRESY PULSE PWM RETIRQ RETNMI RETURN START STOP TIMER TIMER1 TIMER2 TIMERX TIMERY + -
var is a valid variable name var$ is a valid string variable name var() is a valid array name var$() is a valid string array name expression is any expression returning a result expression$ is any expression returning a string result addr is an unsigned integer in the range +/- 16777215 that will be wrapped to the range 0 to 65535 b is a byte value 0 to 255 n is an integer in the range 0 to 63999 w is an integer in the range -32768 to 32767 i is a +ve integer value r is real number +r is a +ve value real number (0 is considered +ve) $ is a string literal
BASIC74 Commands
FLUSHBASIC74 FunctionsThis command, specific to version 1.10 on, clears the input buffer of any pending keystrokes. The buffer is also cleared by CLEAR and RUN.INTx {ON|OFF|CLEAR}Changes INTx event handling (where x is one of 0, 1, 2, 3 or 4).INTx {+|-}ON
Enables the INTx handling subroutine after it has been turned off.OFFNote If a INTx event occured while the INTx event handling was disabled then it will be actioned immediately after this command.
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.CLEARCleares the INTx handling assignment. After an INTx CLEAR the handling subroutine can only be restarted with an ON INTx command.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).CNTRx {+|-}ON
Enables the CNTRx handling subroutine after it has been turned off.OFFNote If a CNTRx event occured while the CNTRx event handling was disabled then it will be actioned immediately after this command.
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.CLEARCleares the CNTRx handling assignment. After a CNTRx CLEAR the handling subroutine can only be restarted with an ON CNTRx command.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).TIMERp {START|STOP}TIMER
The timer (X or Y) counts down (f/16)/(1+PRESq)/(1+TIMERp).PWMIf 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.COUNTThe 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.PULSEAs 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.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).TIMERq <b>ON
Enables the TIMERq handling subroutine after it has been turned off.OFFNote If a TIMERq event occured while the TIMERq event handling was disabled then it will be actioned immediately after this command.
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.CLEARCleares the TIMERq handling assignment. After a TIMERq CLEAR the handling subroutine can only be restarted with an ON TIMERq command.Sets the value of TIMERq (where q is one of 1, 2, X or Y).RETIRQThis command has been removed from EhBASIC74. It's function is now handled by an enhanced RETURN command.RETNMIThis command has been removed from EhBASIC74. It's function is now handled by an enhanced RETURN command.RETURNAs 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.ONSee INTx {ON|OFF|CLEAR}, CNTRx {ON|OFF|CLEAR} or TIMERq {ON|OFF|CLEAR}.OFFSee INTx {ON|OFF|CLEAR}, CNTRx {ON|OFF|CLEAR} or TIMERq {ON|OFF|CLEAR}.CLEARSee 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 {+|-}.
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.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.Returns a boolean value. If any enabled interrupt has occured since EVENT was last examined then EVENT will return -1 else EVENT will return 0TIMERpReturns 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.
Last page update: 9th July, 2003. | e-mail me |