home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
BEEHIVE
/
COMMS
/
MODEM9.ARC
/
SYS.ASM
< prev
next >
Wrap
Assembly Source File
|
1991-02-02
|
13KB
|
539 lines
; 22.11.83
; 8251+8253 SYS.ASM
;
;Intel 8251/8253 support file for MODEM9.xx.
;
;Rename to SYS.ASM before assembly.
;
;This SYS file is presently configured for a 4 MHz M-D.
;
; Three levels of installation and customization are possible.
;
;LEVEL 1. Minimum installation
;
; The user who has ported I/O and who wants to get the program
;operating with minimum effort should:
;
; 1. change the equates for MODDATP, MODCTLP, MODSNDB,
; MODSNDR, MODRCVB and MODRCVR (these six equates
; are crucial to the program's operation)
; 2. change CLKRATE to the appropriate value for their system
; 3. set VERMSG, INIT, SETUP, DISCON, CARDET, EOSCLR, SCRNCLR
; and STRGOK to FALSE
;
;LEVEL 2. Customized installation
;
; The user who wants to refine the program to meet his/her
;communications needs can make simple changes in this file that
;require very little programming skill. As in LEVEL 1, INIT and
;SETUP, DISCON should be set to false. Customization involves one
;or more of the following changes:
;
; 1. In this file:
; a) Set VERMSG to TRUE and enter the name of your computer
; below location SYSVER
; b) Set EOSCLR and SCRNCLR to TRUE and enter the clear-to-end-
; of-screen and home-and-clear equates for your terminal
; at the appropriate locations below
;
; 2. In the file START:
; a) Set the TRUE/FALSE statements in the lookup table which
; begins with BAKUPBYTE and ends with EOFSEND
; b) Change the control characters that are used for local commands,
; this sequence starts with EXITCHR and ends with EXTCHR
; c) Set STROK to TRUE and enter up to ten strings at location
; STRINGS. These strings can be logon sequences or frequently
; used commands that are sent to a remote computer
;
; 3. Change the phone numbers given in the file NUMLIB to systems
; you normally use
;
;LEVEL 3. Modem control
;
; The user who wants the ability to initialize his modem port
;should set INIT to true and write an initialization routine. If on-line
;modem port control is desired and INIT is TRUE, SETUP should be set to
;TRUE and a reinitialization sequence written in. If it is possible to
;disconnect your modem from the telephone line under program control then
;DISCON may be set to true and an appropriate sequence written at location
;DISCR. If you know how to test a modem port for carrier detect set CARDET
;to true and modify the routine at location DETCAR. The routines require
;some programming skill; the second routine is more complex than the first,
;third and fourth.
;
;
VERMSG EQU TRUE ;change to TRUE if you have given at
;location SYSVER the name of the
;system for which MODEM9 has been
;configured.
;
INIT EQU TRUE ;change to TRUE if you are using a
;routine at location INITMOD to
;initialize your modem port on MODEM9
;execution.
;
SETUP EQU TRUE ;change to TRUE if you are using a
;routine at location SETUPR to change
;baud rate, etc.
;
DISCON EQU FALSE ;change to TRUE if you have written a
;routine at location DISCR to disconnect
;the modem from the telephone line.
;
CARDET EQU FALSE ;change to TRUE if you have written a
;routine at location DETCAR to give carrier
;detect status.
;
EOSCLR EQU TRUE ;change to TRUE if you have defined the
;clear to end of screen sequence for
;your terminal. Clear to end of screen is
;used on returning from terminal mode to
;keep the screen from becoming jumbled if
;the remote can positon your cursor.
;
SCRNCLR EQU TRUE ;change to TRUE if you have defined the
;home cursor and clear screen sequence
;for you terminal.
;
MICROD EQU TRUE ;Micro-Decision
;
;THE FOLLOWING MUST BE CHANGED FOR YOUR MICRO IF YOU DON'T HAVE
; A MICRO-DECISION.
MODDATP EQU 0FEh ;data port for MD (8251A)
MODCTLP EQU MODDATP+1 ;modem status port for MD
MODSNDB EQU 01h ;bit to test for ready to send
MODSNDR EQU MODSNDB ;change to 0 if bit is 0 when
;...ready to send
MODRCVB EQU 02 ;bit to test for received data
MODRCVR EQU MODRCVB ;change to 0 if bit is 0 when
;data received
;
CLKRATE EQU 4 ;clock speed in MHz, 8 MHz maximum
;
;CHANGE CLR1, CLR2, CLR3, AND CLR4 TO THE APPROPRIATE VALUES FOR
;YOUR TERMINAL IF EOSCLR IS TRUE
;FREEDOM 100 VALUES:-
IF EOSCLR
CLR1 EQU ESC ;Clear to end
CLR2 EQU 'y' ;of screen sequence
CLR3 EQU 0 ;the unused bytes MUST be 0
CLR4 EQU 0
ENDIF ;EOSCLR
;
;CHANGE SCLR1, SCLR2, SCLR3, AND SCLR4 TO THE APPROPRIATE VALUES FOR
;YOUR TERMINAL IF SCRNCLR IS TRUE
IF SCRNCLR
SCLR1 EQU ESC ;Home cursor
SCLR2 EQU '*' ;and clear screen sequence
SCLR3 EQU 0 ;the unused bytes MUST be 0
SCLR4 EQU 0
ENDIF ;SCRNCLR
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
ORG 140H
;
CLREOS: CALL ILPRT
;
IF EOSCLR
DB CLR1,CLR2,CLR3,CLR4,0
ENDIF ;EOSCLR
;
RET
;
DS CLREOS-$+16
;
CLRSCRN: CALL ILPRT
;
IF SCRNCLR
DB SCLR1,SCLR2,SCLR3,SCLR4,0
ENDIF ;SCRNCLR
;
RET
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
ORG 160H
;
IN$MODCTLP: IN MODCTLP ! RET ;in modem control port
DS IN$MODCTLP-$+16 ;extra space
OUT$MODDATP: OUT MODDATP ! RET ;out modem data port
DS OUT$MODDATP-$+16 ;extra space
IN$MODDATP: IN MODDATP ! RET ;in modem data port
DS IN$MODDATP-$+16 ;extra space
ANI$MODSNDB: ANI MODSNDB ! RET ;bit to test for send ready
DS ANI$MODSNDB-$+16 ;extra space
CPI$MODSNDR: CPI MODSNDR ! RET ;value of send bit when ready
DS CPI$MODSNDR-$+16 ;extra space
ANI$MODRCVB: ANI MODRCVB ! RET ;bit to test for receive ready
DS ANI$MODRCVB-$+16 ;extra space
CPI$MODRCVR: CPI MODRCVR ! RET ;value of receive bit when ready
DS CPI$MODRCVR-$+16 ;extra space
;
ORG 208H
;
SYSVER:
;
;This is where the message goes giving the system for
;which MODEM9 has been customized.
;
CALL ILPRT
DB 'Version for: Micro-Decision',CR,LF,0
RET
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
ORG 6D0H
;
;The following are used in setting up the 8251
;No need to change for another micro if INIT and SETUP are FALSE.
;
;
;control bytes
WORDLEN EQU 4Eh ;8 bits,no parity,1 stop bit
DTR EQU 37h ;turn on DTR,RTS,Error-reset,RxEn,TxEn
MODRESET EQU 0C0h ;bit 6
;
;
;The following is used to initialize the MD on execution of MODEM9.
;
CH2DIV EQU 0F2h ; Micro-Decision
CTCSEL EQU 0F3h ; CTC channel 2
CTCch2 EQU 0BEh ; mode 3
;
IF INIT
;
INITMOD: ; set baudrate in CTC ch 2
mvi a,1 ; 300 baud
sta mspeed ; keep this for standardization
SETBD:
MVI A,CTCch2
OUT CTCSEL ; F3
LDA mspeed ; get baud rate
MOV C,A
;
GETVAL: ; set HL to point to divisor for baud rate
LXI H,BAUDTBL ; point to base of table
MVI B,0
DAD B
DAD B ; HL now points to req'd divisor
;
SETBAUD: ; output divisor bytes to CTC
MOV A,M ; get low byte
OUT CH2DIV ; output it
INX H ; point to high byte
MOV A,M ; get it
OUT CH2DIV ; output it
;
PARM: MVI A,MODRESET ; software reset of modem
OUT MODCTLP ; FF
LDA MODEWORD ; current settings
OUT MODCTLP
MVI A,DTR ; command word
OUT MODCTLP
RET
;
BAUDTBL: ; from SETUP.COM
DW 1136 ;110
DW 417 ;300
DW 208 ;600
DW 104 ;1200
DW 52 ;2400
DW 26 ;4800
DW 13 ;9600
;
ENDIF ;INIT
;
;
IF NOT INIT
INITMOD: RET
ENDIF ;NOT INIT
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
ORG 710H
;
;The following routine changes the baud rate, stop bits and parity
;from the command level. Write your own routine here to change
;your modem parameters. Note the routine MUST modify the parameters
;used by the INITMOD routine.
;
;The following are parameters/masks used in setting word length
;stop bits and parity for the 8251.
;
MSKST EQU 11000000b ;stop bit mask
MSKPA EQU 00110000b ;mask for first two parity bits
MSKWD EQU 00001100b ; word length mask
;
SEVEN EQU 00001000b ;seven bit word
EIGHT EQU 00001100b ;eight bit word
;
ONE EQU 01000000b ;one stop bit
TWO EQU 11000000b ;two stop bits
;
NONE EQU 00000000b ;no parity
ODD EQU 00010000b ;odd parity
EVEN EQU 00110000b ;even parity
;
X16 EQU 00000010b ;X16
;
IF INIT AND SETUP
;
SETUPR:
PUSH H
CALL CLRTST
CALL ILPRT
DB ' UART/Modem Control',CR,LF,LF,LF
DB 'Current settings -',CR,LF,0
CALL SETTIM2
CALL GIVEPRM
CALL ILPRT
DB CR,LF
DB 'Enter choices below - <CR> for no change',CR,LF,0
AGAIN: LXI D,BAUDBUF ;point to input buffer for ILCOMP
CALL ILPRT
DB 'Baud Rate (110, 300, 600, 1200, 2400, 4800, 9600): ',0
CALL INBUFF
LXI D,BAUDBUF+2
CALL ILCOMP ;compare BAUDBUF+2 with characters below
DB '110',0
MVI A,0
JNC OK ;go if got match
CALL ILCOMP
DB '300',0
MVI A,1
JNC OK
CALL ILCOMP
DB '600',0
MVI A,2
JNC OK
CALL ILCOMP
DB '1200',0
MVI A,3
JNC OK
CALL ILCOMP
DB '2400',0
MVI A,4
JNC OK
CALL ILCOMP
DB '4800',0
MVI A,5
JNC OK
CALL ILCOMP
DB '9600',0
MVI A,6
JNC OK
CALL ILCOMP
DB ' ',0
JNC AGAIN2
CALL WRONG
JMP AGAIN ;try again
;
OK: STA INITMOD+1
STA MSPEED
call INITMOD
;
AGAIN2: LXI D,BAUDBUF ;point to input buffer for ILCOMP
CALL ILPRT
DB 'Word Length (7, 8): ',0
CALL INBUFF
LXI D,BAUDBUF+2
CALL ILCOMP ;compare BAUDBUF+2 with characters below
DB '7',0
MVI A,SEVEN
JNC OK2
CALL ILCOMP
DB '8',0
MVI A,EIGHT
JNC OK2
CALL ILCOMP
DB ' ',0
JNC AGAIN3
CALL WRONG
JMP AGAIN2
;
OK2: STA WDLEN
;
AGAIN3: LXI D,BAUDBUF ;point to input buffer for ILCOMP
CALL ILPRT
DB 'Stop Bits (1, 2): ',0
CALL INBUFF
LXI D,BAUDBUF+2
CALL ILCOMP ;compare BAUDBUF+2 with characters below
DB '1',0
MVI A,ONE
JNC OK3
CALL ILCOMP
DB '2',0
MVI A,TWO
JNC OK3
CALL ILCOMP
DB ' ',0
JNC AGAIN4
CALL WRONG
JMP AGAIN3
;
OK3: STA STPLN
;
AGAIN4: LXI D,BAUDBUF ;point to input buffer for ILCOMP
CALL ILPRT
DB 'Parity (None, Even, Odd): ',0
CALL INBUFF
LXI D,BAUDBUF+2
CALL ILCOMP ;compare BAUDBUF+2 with characters below
DB 'NONE',0
MVI A,NONE
JNC OK4 ;go if got match
CALL ILCOMP
DB 'EVEN',0
MVI A,EVEN
JNC OK4
CALL ILCOMP
DB 'ODD',0
MVI A,ODD
JNC OK4
CALL ILCOMP
DB ' ',0
JNC GOSET
CALL WRONG
JMP AGAIN4 ;try again
;
OK4: STA PARIT
;
GOSET: LDA WDLEN
MOV B,A
LDA STPLN
ADD B
MOV B,A
LDA PARIT
ADD B
MOV B,A
LDA SYNC ;x16 clock for 8251A
ADD B
STA MODEWORD
CALL ILPRT
DB CR,LF
DB 'New settings -',CR,LF,0
CALL SETTIM2
CALL GIVEPRM
POP H
JMP INITMOD ;reset 8251
;
GIVEPRM:
CALL GETPRM
CALL ILPRT
DB 'Word length : ',0
LDA WDLEN
CPI SEVEN
JNZ NOTSEV
CALL ILPRT
DB '7',CR,LF,0
JMP GIVEST
NOTSEV: CALL ILPRT
DB '8',CR,LF,0
GIVEST: CALL ILPRT
DB 'Stop bits : ',0
LDA STPLN
CPI ONE
JNZ NOTONE
CALL ILPRT
DB '1',CR,LF,0
JMP GIVEPA
NOTONE: CALL ILPRT
DB '2',CR,LF,0
GIVEPA: CALL ILPRT
DB 'Parity : ',0
LDA PARIT
CPI NONE
JNZ NOTNON
CALL ILPRT
DB 'None',CR,LF,0
RET
NOTNON: LDA PARIT
CPI ODD
JNZ NOTODD
CALL ILPRT
DB 'Odd',CR,LF,0
RET
NOTODD: CALL ILPRT
DB 'Even',CR,LF,0
RET
;
GETPRM: LDA MODEWORD ;get present word length, stop bit and parity
MOV B,A ;save them
ANI MSKWD
STA WDLEN
MOV A,B
ANI MSKST
STA STPLN
MOV A,B
ANI MSKPA
STA PARIT
RET
;
WRONG: CALL ILPRT ;all matches failed - tell operator
DB '++ Incorrect entry ++',CR,LF,BELL,0
RET
;
;
WDLEN: DB EIGHT
STPLN: DB ONE
PARIT: DB NONE
SYNC: db X16
MODEWORD:
DB WORDLEN
;
BAUDBUF:
DB 10,0
DS 10
;
ENDIF ;INIT AND SETUP
;
IF NOT (INIT AND SETUP)
SETUPR: RET
GIVEPRM RET
ENDIF ;NOT INIT AND SETUP
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
ORG 0A70H
;
;For MODEMs which disconnect from the telephone line when data terminal
;ready (DTR) drops, write a routine to disconnect.
;
;
IF DISCON
DISCR: ;write your routine here
RET
ENDIF ;DISCON
;
IF NOT DISCON
DISCR: RET
ENDIF ;NOT DISCON
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ORG 0A90H
;
;
;CTS EQU 10H ;CLEAR TO SEND
;RLSD EQU 80H ;RECEIVED LINE SIGNAL (CARRIER) DETECT
;
IF CARDET
;
DETCAR: ; write your routine here
RET
;
ENDIF ;CARDET
;
;
IF NOT CARDET
;
DETCAR RET
;
ENDIF ;CARDET
;
;
LINK MAIN
;