home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol226 / baudrate.asm < prev    next >
Encoding:
Assembly Source File  |  1986-02-13  |  3.3 KB  |  163 lines

  1. ; BAUDRATE.ASM ver 1.00 as of 07/27/83
  2. ; Written and released to the public domain by
  3. ; S. Kluger, El Paso RCPM
  4. ;
  5. ; This program is currently written for the Compupro
  6. ; Interfacer 4 driving a Televideo 950 terminal.
  7. ;
  8. ; I see no big use in this program, I mainly wrote it out of pure
  9. ; curiosity, since I just installed an Interfacer 4. If you feel
  10. ; any need for it, you're welcome to do with it whatever you want
  11. ; whenever you want, but if you modify and redistribute it,
  12. ; please leave your name in the source file.
  13. ;
  14. ; It does the following:
  15. ;
  16. ; Displays a menu of baud rates on the screen and asks for
  17. ; your choice of console baud rate.
  18. ; After pressing the key of your choice, the program will
  19. ; initialize first the terminal, then the computer console
  20. ; port to the desired baud rate.
  21. ;
  22. ; General EQU's
  23. ;
  24. tpa    equ    100h
  25. bdos    equ    5
  26. print    equ    9
  27. getch    equ    1
  28. cr    equ    0dh
  29. lf    equ    0ah
  30. ;
  31. ; Interfacer 4 equates (the necessary ones only)
  32. ;
  33. base    equ    10h    ;base port address
  34. mode    equ    base+2    ;mode port
  35. select    equ    base+7
  36. relusr    equ    3    ;USART relative user number
  37. offset    equ    4    ;offset rel -> abs
  38. usart    equ    relusr+offset    ;actual USART number
  39. mode1    equ    6eh    ;mode1 byte
  40. mode2    equ    70h    ;mode2 byte less baud rate
  41. ;
  42. ; Terminal equates (for TVI 950)
  43. ; The sequence is ESC { p1 p2 p3 p4, where p1=baud rate,
  44. ;     p2=stop bits, p3=parity, p4=length.
  45. ;     p2..p4 are fixed.
  46. ;
  47. esc    equ    27
  48. cls    equ    26    ;clear screen
  49. prefix    equ    '{'
  50. p2    equ    '0'    ;1 stop bit
  51. p3    equ    '0'    ;no parity
  52. p4    equ    '0'    ;8 bits
  53. ;
  54.     org    tpa
  55. ;
  56. start:    lxi    h,0
  57.     dad    sp
  58.     shld    stksave    ;save stack
  59.     lxi    sp,stack
  60.     lxi    d,menu
  61. tryagn:    mvi    c,print
  62.     call    bdos
  63.     mvi    c,getch
  64.     call    bdos
  65.     call    ucase
  66.     cpi    'A'
  67.     jc    error
  68.     cpi    'P'
  69.     jnc    error
  70. ;
  71. ; we have the response. Now, convert A to something
  72. ; more meaningful to the TVI 950 and send the command
  73. ; string to the terminal.
  74. ;
  75.     sui    10h    ;make range '1'..'?'
  76.     sta    p1
  77.     lxi    d,setterm
  78.     mvi    c,print
  79.     call    bdos
  80.     call    delay
  81. ;
  82. ; now, the USART has to be initialized...
  83. ;
  84.     mvi    a,usart
  85.     out    select
  86.     mvi    a,mode1
  87.     out    mode
  88.     mvi    b,mode2
  89.     lda    p1        ;get baud rate
  90.     ani    0fh        ;strip high nybble
  91. ;
  92. ; since the IF3/4 can do one better than the TVI950, we have to
  93. ;program around that fact. (The IF3/4 can do 2000 baud...)
  94. ;
  95.     cpi    10
  96.     jc    no2000
  97.     inr    a
  98. no2000:    dcr    a
  99.     ora    b        ;finish mode2
  100.     out    mode        ;done!
  101. ;
  102.     lhld    stksave        ;get CP/M stack back
  103.     sphl
  104.     ret
  105. ;
  106. ; delay routine. This routine is needed, since without it
  107. ; I experienced hangup problems in the terminal. Could be that
  108. ; the terminal doesn't get enough time to let the new baud rate
  109. ; take effect...
  110. ;
  111. delay:    lxi    h,0ffffh
  112. dely:    dcx    h
  113.     mov    a,h
  114.     ora    l
  115.     jnz    dely
  116.     ret
  117. ;
  118. ; ucase routine
  119. ;
  120. ucase:    cpi    'a'
  121.     rc
  122.     sui    20h
  123.     ret
  124. ;
  125. ; Come here in case of error
  126. ;
  127. error:    lxi    d,ermenu
  128.     jmp    tryagn
  129. ;
  130. ; setterm - terminal init string
  131. ;
  132. setterm:
  133.     db    esc,prefix
  134. p1:    db    0,p2,p3,p4,'$'
  135. ;
  136. ; this is the baud rate menu
  137. ;
  138. ermenu:    db    7,7,7,7,7,7,7
  139. menu:    db    cls,cr,lf
  140.     db    'Press  To change to baud rate:',cr,lf
  141.     db    '  A       50',cr,lf
  142.     db    '  B       75',cr,lf
  143.     db    '  C      110',cr,lf
  144.     db    '  D      135',cr,lf
  145.     db    '  E      150',cr,lf
  146.     db    '  F      300',cr,lf
  147.     db    '  G      600',cr,lf
  148.     db    '  H     1200',cr,lf
  149.     db    '  I     1800',cr,lf
  150.     db    '  J     2400',cr,lf
  151.     db    '  K     3600',cr,lf
  152.     db    '  L     4800',cr,lf
  153.     db    '  M     7200',cr,lf
  154.     db    '  N     9600',cr,lf
  155.     db    '  O    19200',cr,lf,lf,lf
  156.     db    'Your choice : $'
  157. ;
  158. ;
  159. stksave:dw    0
  160.     ds    50
  161. stack:    equ    $
  162.     end
  163.