home *** CD-ROM | disk | FTP | other *** search
- ;
- ; baudset - an extremely system dependant utility to adjust
- ; the baud rate of the various serial device ports.
- ;
- printf equ 9 ;cp/m's print string function
- tab equ 9 ;tab character (no relation to the above)
- ;
- bdos equ 5 ;to talk to cp/m
- cibuf equ 81h ;start of console input buffer
- tpa equ 100h ;program load address
- ;
- org tpa
- ;
- baudset:
- xra a
- sta doflag
- sta aflag
- sta bflag
- lxi d,cibuf
- nxtdev: call skipbl
- lxi h,devtab
- call search
- jc error
- pchl
- ;
- tuart: call skipbl
- ldax d ;get next non-blank
- cpi 'A' ;which Tuart?
- jnz isitB
- sta Aflag ; 'A'
- lxi h,Adata
- shld lasttu
- jmp getrat
- isitB: cpi 'B'
- jnz error
- sta Bflag ; 'B'
- lxi h,Bdata
- shld lasttu
- getrat: inx d
- call skipbl ;get the next non-blank
- cpi '='
- jnz error ;it must be an equal sign
- inx d
- call skipbl ;get the baud rate
- lxi h,tuatab
- call search
- jc error
- push d
- xchg
- lhld lasttu ;let's see now, where does this go?
- mov m,e
- inx h
- mov m,d ;save the control bytes for later use
- pop d
- call skipbl ;get command terminator character
- ldax d
- inx d
- ana a ;the line ends with a zero
- jz gotops ;if eol, done.
- cpi ';'
- jz nxtdev ;a semicolon starts a device spec
- jmp error ;anything else is incorrect
- ;
- douadr: mvi a,4eh ;defaults:
- ; 8 data bits, 1 stop bit, no parity, 16*rate.
- sta douops
- sta doflag
- ;
- oploop: call skipbl
- lxi h,opstab
- call search ;search option table. get addrs of argument table
- jc error
- call skipbl
- ldax d
- cpi '=' ;skip blanks, then look for an equal sign
- jnz error
- inx d ;skip the equal sign. find the argument.
- call skipbl
- call search ;search the argument table for this value
- jc error
- lda douops
- ana h
- ora l
- sta douops ;adjust the doubler's configuration byte
- call skipbl
- ldax d
- inx d ;point to the next char.
- ora a
- jz gotops ;a zero marks the end of the line
- cpi ','
- jz oploop ;a comma marks the start of another spec
- cpi ';'
- jz nxtdev ;a semicolon marks the start of a device spec
- jmp error ;anything else is a mistake
- ;
- ; skipbl - skip over leading blanks
- ;
- skipbl: ldax d
- cpi ' ' ;space?
- jz skip ; yes: skip it
- cpi tab ;tab?
- rnz ; if not a space and not a tab, return
- skip: inx d
- jmp skipbl ; yes: check next char
- ;
- ; search - searches a table.
- ;
- ; enter with the table address in hl,
- ; and the address of that which is to be matched in de.
- ;
- ; returns carry on failure to match;
- ; returns no carry & routine address in hl on match.
- ;
- nomat: pop d
- dad b
- inx h
- inx h ;point to next item in table
- ;
- search: mov c,m
- inx h
- mov b,m
- inx h ;get length of item in bc
- ;
- mov a,c
- ora b
- jz nofind ;reached end of table with no match?
- push d ;no: save start of name pointer
- ;
- nxtch: call skipbl ;ignore spaces
- cmp m ;match?
- jnz nomat
- inx h
- inx d
- dcx b ;yes, a match...bump pointers, decr counter
- mov a,c
- ora b ;reached end of item yet?
- jnz nxtch
- ;
- match: pop b ;get start of item address off stack
- mov a,m
- inx h
- mov h,m
- mov l,a ;get service routine address
- xra a ;indicate succesful match
- ret
- ;
- nofind: stc
- sbb a ;indicate failure to match
- ret
- ;
- ; gotops - sets the devices to their new baud rates.
- ;
- gotops: lda doflag
- ana a
- jz goa ;no: try tuart a
- lxi h,0fe0ah ;the Doubler's command address.
- mvi m,0
- nop! nop
- mvi m,0
- nop! nop
- mvi m,0
- nop! nop
- mvi m,50h ;internal reset + error reset
- nop! nop
- lda douops
- mov m,a
- nop! nop
- mvi m,2eh ;RTS + DTR + Rx + Tx
- goa: lda aflag
- ana a ;is tuart 'A' to be altered?
- jz gob ; no: try tuart 'B'
- lda adata ; yes: change it.
- out 0
- lda adata+1
- out 2
- gob: lda bflag
- ana a ;is tuart 'B' to be altered?
- rz ; if not, we're done, so back to cp/m
- lda bdata
- out 50h
- lda bdata+1
- out 52h
- ret
- ;
- ; error - sends an error message to the console
- ;
- errmsg: db '--error--$'
- error: mvi a,'?'
- stax d
- lxi h,80h ;char count
- mvi a,81h ;start of string
- add m
- mov l,a
- mvi m,'$'
- lxi d,errmsg
- mvi c,printf
- call bdos
- lxi d,81h
- mvi c,printf
- jmp bdos ;returns to cp/m after printing message
- ;
- ; devtab - table of device name lengths,
- ; device names,
- ; and service routine addresses.
- ;
- devtab:
- dw tualen
- tuasta equ $
- db 'TUART'
- tualen equ $-tuasta
- dw tuart
- ;
- dw doulen
- dousta equ $
- db 'DOUBLER'
- doulen equ $-dousta
- dw douadr
- ;
- dw 0 ;end of table marker
- ;
- ; tuatab - a table listing the baud rates avalible for the
- ; 5501's on the Cromemco Tuart board.
- ;
- tuatab:
- dw 5
- db '19200'
- dw 1090h
- dw 5
- db '19.2K'
- dw 1090h
- dw 4
- db '9600'
- dw 00c0h
- dw 4
- db '4800'
- dw 00a0h
- dw 4
- db '2400'
- dw 0090h
- dw 4
- db '1200'
- dw 0088h
- dw 3
- db '300'
- dw 0084h
- dw 3
- db '150'
- dw 0082h
- dw 3
- db '110'
- dw 0001h, 0
- ;
- ; opstab - a table listing the options which may be specified
- ; to correctly set up the 8251 on the doubler.
- ;
- opstab:
- dw rateln-$-2
- db 'RATEFACTOR'
- rateln equ $
- dw ratetb
- dw bitsln-$-2
- db 'DATABITS'
- bitsln equ $
- dw bitstb
- dw stopln-$-2
- db 'STOPBITS'
- stopln equ $
- dw stoptb
- dw pariln-$-2
- db 'PARITY'
- pariln equ $
- dw paritb, 0
- ;
- ; ratetb - a table listing the multiplication factors avalible
- ; for the 8251 on the Micromation Doubler board.
- ;
- ratetb:
- dw 2
- db '64'
- dw 0fc03h
- dw 2
- db '16'
- dw 0fc02h
- dw 1
- db '1'
- dw 0fc01h, 0
- ;
- ; bitstb - a table listing the number of data bits avalible
- ; for the 8251 on the Micromation Doubler board.
- ;
- bitstb:
- dw 1
- db '5'
- dw 0f300h
- dw 1
- db '6'
- dw 0f304h
- dw 1
- db '7'
- dw 0f308h
- dw 1
- db '8'
- dw 0f30ch, 0
- ;
- ; paritb - a table listing the parity options avalible
- ; for the 8251 on the Micromation Doubler board.
- ;
- paritb:
- dw 4
- db 'NONE'
- dw 0cf00h
- dw 3
- db 'ODD'
- dw 0cf10h
- dw 4
- db 'EVEN'
- dw 0cf30h, 0
- ;
- ; stoptb - a tale listing the stop bit options avalible
- ; for the 8251 on the Micromation Doubler board.
- ;
- stoptb:
- dw 1
- db '2'
- dw 03fc0h
- dw 3
- db '1.5'
- dw 03f80h
- dw 1
- db '1'
- dw 03f40h, 0
- ;
- doflag: ds 1
- aflag: ds 1
- bflag: ds 1
- ;
- lasttu: ds 2 ;points to adata or bdata
- adata: ds 2 ;data for tuart 'A'
- bdata: ds 2 ;data for tuart 'B'
- douops: ds 1 ;data for the Doubler
- ;
- end baudset
-