beautypg.com

Measurement Computing Personal488 rev.3.0 For DOS & Windows 3.Xi User Manual

Page 130

background image

II. SOFTWARE GUIDES - 8. Driver488/DRV

8M. Data Transfers

Personal488 User’s Manual, Rev. 3.0

II-115

When performing a binary

ENTER

, Driver488/DRV does not check for

TERM

input terminators when

reading from the bus, nor does it provide

EOL

input terminators to the program. The data is returned to

the program just as it is received from the bus device. The

INPUT$

function which is designed to read

a specific number of characters from a file or device, is ideal for reading the result from
Driver488/DRV. Note that a normal

INPUT

statement does not work, as Driver488/DRV does not

provide the

EOL

input terminators on binary

ENTER

s.

Buffered I/O

In buffered I/O, the program does not transfer data to or from Driver488/DRV. All it does is send the
address and quantity of data to be transferred, and Driver488/DRV takes care of the details of the
transfer. The program must be able to tell Driver488/DRV when in memory to find the data. In other
words, it must be able to provide Driver488/DRV with the actual memory address of the buffer. In
BASIC, the capability is partially provided by the

VARPTR

function.

VARPTR

returns a number from

0

to

65,535

giving the address of its argument. For example:

PRINT VARPTR(A%(0))

prints the address of the first byte of the

A%

array. This address, however, is relative to the start of

BASIC’s data segment.

The first three statements ask Driver488/DRV for the location of its callable subroutines, and configure
BASIC (via the

DEF SEG

statement) to be able to call them. The

offset

of

GET.SEGMENT

, which is

0

, from the start of the

IEEESEG

area must be specified, and then

GET.SEGMENT

can be called. The

VARSEG

function is used in a similar manner to determine the value of the BASIC data

segment

. This

data segment value remains fixed during program execution, and so these statements need only be
performed once to set the value of the data segment.

With the data segment value determined, and the

VARPTR

function able to find the

offset

s into that

segment

, we are able to completely specify the memory address of any BASIC variable or array.

However, character string variables, such as

A$

, are not stored in the same manner as numeric variables

and are not recommended for

BUFFERED

I/O.

The following is a typical

BUFFERED ENTER

command:

DIM W%(10)
PRINT#1,"ENTER 12 #20 BUFFER"; VARSEG(W%(1)); “:”; VARPTR(W%(1))

The

PRINT

statement in this example sends to Driver488/DRV the command (

ENTER

), the bus device

address (

12

) and number of bytes to transfer (

20

), the

BUFFER

keyword, the

segment

(

VARSEG(W%(1)

), a colon character (

:

) that lets Driver488/DRV know that the memory address is

given as a

segment

followed by an

offset

, and the

offset

(

VARPTR(W%(1)

). If BASIC’s

segment

and

offset

to

W%(1)

are

2540

and

1320

, respectively, then the

PRINT

statement would send:

“ENTER 12 #20 BUFFER 2450:1320”

to Driver488/DRV. This gives Driver488/DRV all the information it needs to be able to transfer the
received data directly into the

W%

array.

BUFFERED OUTPUT

is also possible. For example, say we wanted to send the data just received in the

example above to a device

17

. We would use the following command:

PRINT#1,"OUTPUT17 #20 BUFFER"; VARSEG(W%(1)); “:”; VARPTR(W%(1))

Normally,

BUFFERED

I/O is performed without any terminator detection. However, it is possible to

explicitly specify that the

ENTER

should stop on detection of

EOI

, or on detection of

EOI

or some

single character. For example, if we want to terminate on

EOI

:

PRINT#1,"ENTER 12#20 BUFFER"; VARSEG(W%(1));“:”; VARPTR(W%(1));“EOI”

Finally, just as we can perform direct binary

OUTPUT

, we can also perform direct binary

ENTER

:

PRINT#1,"ENTER 16#128"
A$=INPUT$(128,2)