$save nolist %';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %' %' TITLE: DTHCNF.MAC %' %' DATE: 5-19-82 %' %' ABSTRACT: This module contains definitions for the Terminal %' Handler configuration macros: MTH, TH_TIMER, TH_USART, %' TH_INT_LEVELS, TH_MAILBOX_NAMES, TH_19200_BAUD_COUNT, %' AND TH_CHAR_LENGTH. These macros allow the user to %' specify the terminal response characteristics, the %' baud rate, the USART and Timer components, the %' interrupt levels, the input and output mailbox names %' used and the length in bits of the character received %' from the terminal. Including this module in an assembly %' module will generate the default configuration which %' identifies the iSBC-86/12A as the hardware the %' Terminal Handler will run on. %' %';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %' %' First define some utility macros to cleanup the %' parameters passed to the configuration macros. %' %';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %' %' Define strings for strip. %' %define(crlf) ( ) %define(cr) ( ) %define(lf) ( ) %define(tab) ( ) %define(space) ( ) %define(dol) ($) %' %' Strip: %' strip all occurances of "char" string from "arg" string. %' %*define(strip(char,arg)) local str head tail (%' %' '%define(str) (%0)%' %' '%define(tail) (%arg)%' %' '%while(%nes(%tail,%0)) (%' %' '%match(head%(%char)tail) (%tail)%' %' '%define(str) (%str%head)%' %' ')%' %' '%str%' )%' %' %' Cleanup: %' strip $s, spaces, tabs, CRLFs from string. %' %*define(cleanup(str)) (%strip(%dol,%strip(%space,%strip(%tab,%strip(%cr,%strip(%lf,%str)))))) %' %';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %' %' TITLE: TH_19200_BAUD_COUNT %' %' INPUTS: 19200_COUNT - a value which will generate a baud rate %' of 19200 baud at the input clock freguency used. %' %' OUTPUTS: none directly, it sets up 19200_count for use by MTH. %' %' ABSTRACT: %' The value _19200_count is used in the MTH macro to set the %' timers count to generate the baud rate. This macro only %' inputs the value and does not alter any parameters itself. %' If the Timer clock frequency is changed this macro must be %' invoked before the MTH macro. %' %';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %*define(th_19200_baud_count(_19200_count_p))(%' %' %set(_19200_count,%cleanup(%_19200_count_p)) %IF (%_19200_count le 1) THEN ( ERROR -- 19200_COUNT MUST BE GREATER THAN 1)FI%' )%' end TH_19200_BAUD_COUNT macro %' %';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %' %' TITLE: MTH %' %' INPUTS: RATE - the baud rate the terminal is to run at. %' RUBOUT - the sytle of rubout to be used. %' BLANK - the character to be used as the rubout char. %' %' OUTPUTS: RQRATE - the baud rate %' RQRUBOUT - the rubout style %' RQBLANK - the rubout character. %' %' ABSTRACT: MTH orgs into th_cnf_seg1 and defines values for %' RQRATE, RQRUBOUT and RQBLANK. MTH uses the value %' 19200_count set up by the TH_19200_BAUD_COUNT macro %' to compute the value necessary to generate the baud %' rate specified in the MTH macro. If the USART input %' clock frequency is changed, the TH_19200_BAUD_COUNT %' and the MTH macros must be reinvoked. The %' TH_19200_BAUD_COUNT macro must always be invoked %' prior to invoking MTH macro. %' %';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %*define( mth(rate_p,rubout_p,blank_p))(%' %' %set(rate,%cleanup(%rate_p)) %set(rubout,%cleanup(%rubout_p)) %set(blank,%cleanup(%blank_p)) %' %IF (%rate eq 19200) THEN (%set(mult,1)) ELSE (%' %IF (%rate eq 9600) THEN (%set(mult,2)) ELSE (%' %IF (%rate eq 4800) THEN (%set(mult,4)) ELSE (%' %IF (%rate eq 2400) THEN (%set(mult,8)) ELSE (%' %IF (%rate eq 1200) THEN (%set(mult,16)) ELSE (%' %IF (%rate eq 600) THEN (%set(mult,32)) ELSE (%' %IF (%rate eq 300) THEN (%set(mult,64)) ELSE (%' %IF (%rate eq 150) THEN (%set(mult,128)) ELSE (%' %IF (%rate eq 110) THEN (%set(mult,175)) ELSE (%' ERROR -- INVALID BAUD RATE %set(mult,0))FI%' )FI )FI )FI )FI )FI )FI )FI )FI%' th_cnf_seg1 segment byte public 'CODE' org 0 dw %rate db %rubout db %blank dw (%_19200_count * %mult) th_cnf_seg1 ends )%' end of MTH macro %' %';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %' %' TITLE: TH_TIMER %' %' INPUTS: TIMER_BASE_PORT - the numerically lowest port in the %' timer connected to the USART clock input. %' BAUD_COUNTER - the counter in the Timer used for USART %' clock input, only values 0-2 are valid. %' %' OUTPUTS: TIMER_CONTROL - the timer control port %' BAUD_COUNTER - the counter port connected to the USART %' COUNTER_SELECT - the code to select the desired counter %' when programming the Timer. %' TIMER_PORT_DELTA - the spacing between ports on the timer. %' %' ABSTRACT: TH_TIMER orgs to 0 in the th_cnf_seg2 to define %' values for its outputs. %' %';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %*define(th_timer(timer_base_port_p,baud_counter_p,timer_port_delta_p))(%' %' %set(timer_base_port,%cleanup(%timer_base_port_p)) %' timer_base_port is the lowest valued port on the Timer. %' %set(baud_counter,%cleanup(%baud_counter_p)) %set(timer_port_delta,%cleanup(%timer_port_delta_p))%' %if(%eqs(%timer_port_delta,%0))%' then (%set(timer_port_delta,2))fi%' %' %' Set up the timer select code for the control word %' %IF (%baud_counter eq 0) THEN (%set(baud_counter_code,0)) ELSE (%' %IF (%baud_counter eq 1) THEN (%set(baud_counter_code,40h)) ELSE (%' %IF (%baud_counter eq 2) THEN (%set(baud_counter_code,80h)) ELSE (%' ERROR -- BAUD COUNTER NUMBER NOT 0, 1 OR 2 %set(baud_counter_code,0) )FI )FI )FI %' th_cnf_seg2 segment byte public 'CODE' org 0 dw %eval(%timer_base_port + (3 * %timer_port_delta)) dw %eval(%timer_base_port + (%baud_counter * %timer_port_delta)) dw %baud_counter_code th_cnf_seg2 ends )%' end of TH_TIMER macro %' %';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %' %' TITLE: TH_USART %' %' INPUTS: USART_BASE_PORT - the numerically lowest valued port %' in the USART used. %' USART_PORT_DELTA - the spacing between ports on the usart. %' %' OUTPUTS: USART_STATUS - the USART status port %' USART_CONRTOL - the USART control port %' USART_IN - the USART input port %' USART_OUT - the USART output port %' %' ABSTRACT: TH_USART orgs to 0 in the th_cnf_seg3 to define %' values for its outputs. %' %';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %*define(th_usart(usart_base_port_p,usart_port_delta_p))(%' %' %set(usart_base_port,%cleanup(%usart_base_port_p)) %set(usart_port_delta,%cleanup(%usart_port_delta_p)) %if(%eqs(%usart_port_delta,%0))%' then (%set(usart_port_delta,2))fi%' %' th_cnf_seg3 segment byte public 'CODE' org 0h dw %usart_base_port dw %usart_base_port dw %eval(%usart_base_port + %usart_port_delta) dw %eval(%usart_base_port + %usart_port_delta) th_cnf_seg3 ends )%' end of the TH_USART macro %' %';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %' %' TITLE: TH_INT_LEVELS %' %' INPUTS: INPUT_LEVEL - the interrupt level used for character %' input. Connected to the RXRDY line of the USART. %' OUTPUT_LEVEL - the interrupt level used for character %' output. Connected to the TXRDY line of the USART. %' %' OUTPUTS: INPUT_INTERRUPT_LEVEL - the input interrupt level. %' OUTPUT_INERRUPT_LEVEL - the output interrupt level. %' %' ABSTRACT: TH_INT_LEVELS orgs to 0 in the th_cnf_seg4 to define %' values for its outputs. %' %' -- NOTE -- %' The interrupt levels specified are RMX/86 encoded levels. %' They must be represented as hex numbers -- 036H %' %';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %*define(th_int_levels(input_level_p,output_level_p))(%' %' %set(input_level,%cleanup(%input_level_p)) %set(output_level,%cleanup(%output_level_p)) %' th_cnf_seg4 segment byte public 'CODE' org 0 dw %input_level dw %output_level th_cnf_seg4 ends )%' TH_INT_LEVELS macro ends %' %';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %' %' TITLE: TH_CHAR_LENGTH %' %' INPUTS: LENGTH - the length in bits of the character %' received from the terminal. This value can be only %' 7 or 8. %' %' OUTPUTS: CHAR_LENGTH_MASK - the mask for the input character %' which determines how many valid bits the character is. %' %' ABSTRACT: TH_CHAR_LENGTH orgs to 0 in the th_cnf_seg5 to %' define values for its output. %' %';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %*define(th_char_length(length_p))(%' %' %set(length,%cleanup(%length_p)) %' %IF (%length eq 7) THEN (%set(length_mask,07fh)) ELSE (%' %IF (%length eq 8) THEN (%set(length_mask,0ffh)) ELSE (%' ERROR -- INVALID CHARACTER LENGTH, NOT 7 OR 8 %set(length_mask,0) )FI )FI %' th_cnf_seg5 segment byte public 'CODE' org 0 dw %length_mask th_cnf_seg5 ends )%' end TH_CHAR_LENGTH macro %' %';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %' %' TITLE: TH_MAILBOX_NAMES %' %' INPUTS: INPUT_MBX - the name of the input mailbox %' OUTPUT_MBX - the name of the output mailbox. %' %' OUTPUTS: NORM_INPUT_MAILBOX - an RMX/86 string containing %' the name of the input mailbox. %' NORM_OUTPUT_MAILBOX - an RMA/86 string containing %' the name of the output mailbox. %' %' ABSTRACT: TH_MAILBOX_NAMES orgs to 0 in the norm_in_mbx_seg %' and the norm_out_mbx_seg to define the first byte as %' length of the mailbox name and subsequent bytes up to %' 12 as the name of the mailbox to be used for input and %' output respectively. %' %';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %*define(th_mailbox_names(input_mbx_p,output_mbx_p))(%' %' %define(input_mbx)(%cleanup(%input_mbx_p)) %IF (%len(%input_mbx) gt 12) THEN ( ERROR -- INPUT MAILBOX NAME LONGER THAN 12 CHARACTERS ) ELSE (%' norm_in_mbx_seg segment byte public 'CODE' org 0 db %len(%input_mbx),'%input_mbx' norm_in_mbx_seg ends )FI%' %' %define(output_mbx)(%cleanup(%output_mbx_p)) %IF (%len(%output_mbx) gt 12) THEN ( ERROR -- OUTPUT MAILBOX NAME LONGER THAN 12 CHARACTERS ) ELSE (%' norm_out_mbx_seg segment byte public 'CODE' org 0 db %len(%output_mbx),'%output_mbx' norm_out_mbx_seg ends )FI%' )%' TH_MAILBOX_NAMES macro ends %' %';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; %' %' -- IN-LINE CODE GENERATED BY INCLUDING THIS MODULE. -- %' %' The following code will be assembled just by including this %' macro file in another module. All values are initialized to %' the default 86/12A values and then are redefined by optional %' invocations of any number of the TH configuration macros. %' The only constraint on the order the macros may be invoked in %' is when the Baud Rate Timer uses a clock frequency different %' than the iSBC-86/12A, 1.2288 MHz. At that time, the %' TH_19200_BAUD_COUNT macro must be invoked with a new count value %' which will generate 19200 Baud at the new frequency. It must %' be invoked before the MTH macro specifying the Baud Rate. If %' the clock frequency is changed, the Baud Rate must be specified %' again. Other than this case, the macros may be invoked in any %' order desired. %' cgroup group th_cnf_seg1, th_cnf_seg2, th_cnf_seg3, th_cnf_seg4, & th_cnf_seg5, norm_in_mbx_seg, norm_out_mbx_seg assume cs:cgroup public norm_input_mailbox, norm_output_mailbox public rqrate,rqrubout,rqblank public timer_control,baud_counter,counter_select,baud_rate_count public usart_in,usart_out,usart_status,usart_control public input_interrupt_level,output_interrupt_level public char_length_mask %' %' -- NOTE!!! -- %' The order of the declarations within the five TH_CNF_SEGs cannot %' be changed because the configuration macros org to 0 in those %' segments to define values for the variables declared by the %' in-line assembly code. The order of variable declaration done %' by the in-line code and the definition of values done by the %' macros must exactly match. %' %' -- DO NOT ARBITRARILY REORGANIZE THEM!!! -- %' %' the values of the variables in th_cnf_seg1 are set by MTH th_cnf_seg1 segment byte public 'CODE' org 0 rqrate dw ? rqrubout db ? rqblank db ? baud_rate_count dw ? th_cnf_seg1 ends %' %' the values of the variables in th_cnf_seg2 are set by TH_TIMER th_cnf_seg2 segment byte public 'CODE' org 0 timer_control dw ? baud_counter dw ? counter_select dw ? th_cnf_seg2 ends %' %' the values of the variables in th_cnf_seg3 are set by TH_USART th_cnf_seg3 segment byte public 'CODE' org 0 usart_in dw ? usart_out dw ? usart_status dw ? usart_control dw ? th_cnf_seg3 ends %' %' the values of the variables in th_cnf_seg4 are set by TH_INT_LEVELS th_cnf_seg4 segment byte public 'CODE' org 0 input_interrupt_level dw ? output_interrupt_level dw ? th_cnf_seg4 ends %' %' the values of the variables in th_cnf_seg5 are set by TH_CHAR_LENGTH th_cnf_seg5 segment byte public 'CODE' org 0 char_length_mask db ? th_cnf_seg5 ends %' %' open segments for the input and output mailbox names %' and declare the variable names %' norm_in_mbx_seg segment byte public 'CODE' norm_input_mailbox db ? norm_in_mbx_seg ends %' norm_out_mbx_seg segment byte public 'CODE' norm_output_mailbox db ? norm_out_mbx_seg ends %' %' Invoke all the TH cnfiguration macros with the default %' iSBC-86/12A values. These will be modified by subsequent %' invocations of any of the TH configuration macros. %' %th_19200_baud_count(4) %mth(9600,2,020h) %th_timer(0D0H,2,2h) %th_usart(0D8H,2h) %th_int_levels(68H,78H) %th_char_length(7) %th_mailbox_names(RQTHNORMIN,RQTHNORMOUT) $restore