
7-6
Section
Details of BASIC Commands
178
on com
Syntax:
ON COM
[<port expression>]
GOSUB
(<line number> | <label>) [ , (
CODE
[= <code expression>] |
BYTE
= <byte expression>) |
HEAD
= <code expression> , (
TERM
[ = <code expression >] |
BYTE
=
<byte expression >)]
Description:
Statement. Defines an interrupt subroutine to handle interrupts from the communication ports and
interrupt formats. There are 5 possible formats: 1) Interrupt after reception of any kind of data, 2)
Reception of the specified character, 3) Reception of the specified number of bytes, 4) Reception
of the specified header character and terminating character, or 5) Reception of the specified
header character and number of bytes.
Remarks:
<port expression> is an expression returning an integer in the range: [1… 2].
If <port expression> is omitted
ON COM
operates on all ports.
<line number> specifies the line at the start of the interrupt subroutine (ISR).
<label> is a BASIC program label. It references a line number at the start of the ISR.
The ISR should be terminated by a
RETURN
statement. When the
RETURN
statement is reached
execution will resume at the statement that was originally interrupted.
In the body of the ISR, the user should check the contents of the buffer before manipulating the
data. It is possible that the
ON COM
has been held pending and in the meantime, the buffer data has
been changed.
<code expression> defines an ASCII code for a single byte character. Valid range is [0…255].
<byte expression> defines a number of bytes that can be entered before the interrupt takes place. Valid range
is [1…255].
ON COM
interrupts can be used in 5 different ways:
1.
ON COM
[<port>]
GOSUB
xxxx
2.
ON COM
[<port>]
GOSUB
xxxx,
CODE
= xx
3.
ON COM
[<port>]
GOSUB
xxxx,
BYTE
= yy
4.
ON COM
[<port>]
GOSUB
xxxx,
HEAD
= xx1,
TERM
= xx2
5.
ON COM
[<port>[
GOSUB
xxxx,
HEAD
= xx,
BYTE
= yy
Case (1): Interrupt occurs when communication port buffer receives any character.
Case (2): Interrupt occurs for a specific character xx. If xx is omitted then the default character
string to initiate the interrupt is a CR.
Case (3): Interrupt occurs after a specified number of characters have been received, i.e. on the
yyth byte. The number specified must be in the range [1…255].
Case (4): Interrupt is enabled after the starting character xx1 is received and occurs after the
terminating character xx2 is received. All characters from xx1 to xx2 are retained in the
communication buffer. If the terminating character xx2 is omitted the default character string to
initiate the interrupt is a CR.
Case (5): Interrupt is enabled after the starting character xx is received and occurs after yy
characters have been received. All yy characters from xx are retained in the communication
buffer.
Once an interrupt has been serviced, all subsequent BASIC interrupts are
STOP
ped until the
RETURN
statement has been executed.
On executing the corresponding
ON COM
ISR, all subsequent BASIC interrupts are
STOP
ped, i.e.
held pending during execution of the ISR. After the ISR has returned, pending interrupts are
executed and the BASIC interrupts are returned to their previous states. Only one interrupt of the
same type as the currently active interrupt can be held pending, subsequent interrupts of that type
are lost.
Содержание C200H-ASC11
Страница 1: ...C200H ASC11 ASC21 ASC31 ASCII Units Operation Manual Revised June 2000...
Страница 2: ...iv...
Страница 4: ...vi...