The Quebec Link

See all articles from Sinc-Link v9 n2
Author(s): Real Gagnon
Publication: Sinc-Link
Pub Details: Sinc-Link v9 n2 (Volume 9, Issue 2)
Date: March/April 1991
Pages: 12-13

The last version of ARCHIVE, called ARCdev and ARCrtm, introduces the possibility to call external machine code routine to complement the ARCHIVE programming language. This is also true for the PSION XCHANGE software.

We load the external routines, with LOAD USR ‘filename’ the default extension is ‘_pmc’.

and we call them with LET x=USR(par1,’par2$’).

The first parameter, PAR1, is a number and the second one (PAR2$), a string. Note that even if PAR2$ is a variable, we have to put quotes around it. The variable X will contain an error code in the QDOS tradition.

From the programming point of view, the routine must begin with a 6 bytes header like this:

DC.B 'pmc0'
DC.W routine_length

The register D0 contains the value of PAR1 and A0 is pointing to PAR2$. The first byte of PAR2$ is length of the string.

Only one ‘_pmc’ file can be in memory. But it is possible to develop a toolkit for ARCHIVE and use PAR1 to select the different routines by testing the value of D0 in our program:

ex.  ROUTINE_0  DBF d0,ROUTINE_1
...
RTS
ROUTINE_1 DBF d0,ROUTINE_2
...
RTS
ROUTINE_2 DBF d0,ERROR
...
ERROR MOVEQ #-15,d0
RTS

PAR2$ can pass more than one parameter by using the ascii code of each character. With this method each parameter can have a value between 0-255. For example, if the routine 2 of our imaginary toolkit is to produce a beep, the first parameter can be the tone and the second, the length. For example, if we need a tone of 20 of length 5, this can be coded with LET beep$=CHR(20)+CHR(5) and called with LET x=USR(2,’beep$’).

The following utility will permit to ARCHIVE to communicate via the SER2 port. We will use it to dial a phone number by sending the appropriate command to a modem.

In ARCHIVE, load SER2_pmc with LOAD USR ‘SER2’. If you want to dial a number and your modem is HAYES compatible then type LET number$=’ATDT1234567’+CHR(13) .

‘ATDT’ is a command to dial a number on a TOUCH TONE line, if you have a PULSE line use ‘ATDP’ instead. You have to terminate the variable number$ with CHR(13) to force to modem to execute the command.

To start the dialing type LET x=USR(speed,’number$’) where speed represents to baud rate specific to your modem. Speed equals to 0 for 75 bauds, 1 for 300, 2 for 600, 3 for 1200, 4 for 2400, 5 for 4800, 6 for 9600 and 7 for 19200!

While the modem dials the number pick up the phone. After the dialing, the modem must hang up the phone. Just send a carriage return to the modem, this will put it off line right away.

let number$='ATDT1234567'+chr(13)
let hangup$=chr(13)
let x=usr(3,'number$')
print 'Press a key to put the modem
off line after the dialing.'
input dummy$
let x=usr(3,'hangup$')

Say you have a database containing a membership list for your bowling club. The phone number of each member is given by the field phone$. To call Joseph, find his record and issue the following commands to dial his number:

let number$='ATDT'+phone$+chr(13)
let x=usr(3,'number$')

To create SER2_pmc, type in the BASIC loader and run it.

I repeat, this will not work with ARCHIVE 2.3 or 2.35. You need ARCdev/ARCrtm (also called ARCHIVE run-time) or the PSION XCHANGE which is a combinaison of QUILL/ARCHIVE/EASEL/ABACUS into one big program. I have developped SER2_pmc with XCHANGE v3.27, I don’t have ARCdev…

SER2_pmc BASIC LOADER

100 REMark LOADER for SER2_pmc
110 REMark by Real Gagnon, Montreal Quebec dec90
120 :
130 CLS:INPUT "SAVE SER2_pmc WHERE? (default flp1_)?";sauve$
140 IF LEN(sauve$)=0:sauve$="flp1_"
150 PRINT "One moment please.";
160 :
170 RESTORE 1000
180 memoire=RESPR(512):base_memoire=memoire
190 compte=0 : checksum=6567 : checkme=0
200 :
210 REPeat loop
220 IF EOF:EXIT loop
230 READ byte:POKE memoire,byte:memoire=memoire+1
240 compte=compte+1
245 checkme=checkme+byte
250 PRINT ".";
260 END REPeat loop
265 :
270 IF checkme<>checksum:PRINT "Checksum incorrect":STOP
280 :
290 SBYTES sauve$&'SER2_pmc',base_memoire,compte
300 PRINT 'Ok!':STOP
310 :
1000 DATA 112, 109, 99, 48, 0, 86, 38, 72, 65, 250
1001 DATA 0, 66, 50, 24, 81, 200, 255, 252, 112, 18
1002 DATA 78, 65, 114, 255, 38, 60, 0, 0, 0, 0
1003 DATA 65, 250, 0, 36, 112, 1, 78, 66, 74, 64
1004 DATA 102, 0, 0, 24, 20, 27, 72, 130, 118, 255
1005 DATA 34, 75, 112, 7, 78, 67, 74, 64, 102, 0
1006 DATA 0, 6, 112, 2, 78, 66, 78, 117, 0, 6
1007 DATA 83, 69, 82, 50, 105, 114, 0, 75, 1, 44
1008 DATA 2, 88, 4, 176, 9, 96, 18, 192, 37, 128
1009 DATA 75, 0

The Quebec Link… (SER2_pmc source)

*********************************************************
* filename : SER2_pmc version 1.0 *
* date : december 1990 *
* *
* Machine code extension for ARCHIVE 2.38 and XCHANGE *
* to add the possibility to talk directly to the *
* SER2 port. *
* *
* LOAD with the command LOAD USR 'ser2' *
* USE with the command *
* LET result=USR(speed,'string$') *
* where speed is the baud rate to be used *
* 0=75 1=300 2=600 3=1200 4=2400 *
* 5=4800 6=9600 7=19200 *
* where strings$ is the variable name *
* containing the string to be sent. *
* note that you have to put quotes around *
* it. *
* *
* the routine returns an error code in the *
* variable result if any. 0 = no error *
* other = error *
* *
* This program is donated to the public domain *
* *
* written by Real Gagnon and HIC LOGIQUE *
* [address omitted] P.O. Box 1393 *
* Place du Parc *
* Montreal Quebec *
* CANADA H2W 2R4 *
*********************************************************
MT_BAUD equ $12 set the baud rate
IO_OPEN equ $1 open a channel
IO_CLOSE equ $2 close a channel
IO_SSTRG equ $7 send a string to a channel
THIS_JOB equ -1

header dc.b 'pmc0'
dc.w finish-start
*-------------------------------------
* A0 contains the pointer of the string to be sent.
* D0 contains the baud rate to be used
*-------------------------------------
*-------------------------------------
* set the baud rate
*-------------------------------------
start move.l a0,a3 preserve the string address
lea baud_choice,a0 find the correct baud rate
baud_loop move.w (a0)+,d1
dbra d0,baud_loop
moveq #MT_BAUD,d0
trap #1
*-------------------------------------
* open a channel for SER2
*-------------------------------------
moveq #THIS_JOB,d1
move.l #0,d3 we open a channel for a device
lea device_name,a0
moveq #IO_OPEN,d0
trap #2 open the channel
tst d0 error?
bne error_detected
*-------------------------------------
* A0 contains the CHANNEL ID (needed for IO_SSTRG)
* now we have to send the string pointed by A4
*-------------------------------------
move.b (a3)+,d2 length of the string
ext.w d2
moveq #-1,d3 no timeout
move.l a3,a1 string address
moveq #IO_SSTRG,d0
trap #3
tst d0
bne error_detected
*-------------------------------------
* now, we close the channel (A0 still contains CHANNEL ID
)
*-------------------------------------
exit_send moveq #IO_CLOSE,d0
trap #2
error_detected rts go back to ARCHIVE/XCHANGE

device_name dc.w 6 length of the device name
dc.b 'SER2ir' no handshake and no parity

baud_choice dc.w 75,300,600,1200,2400,4800,9600,19200

finish end
Digitised pictures of three faces
Digitised pictures of three faces

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.