home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol177 / setbaud.asm < prev    next >
Encoding:
Assembly Source File  |  1985-02-10  |  2.5 KB  |  136 lines

  1. ;SETBAUD.ASM v 1.00 as of 08/21/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 using relative ports 1 and 2.
  7. ; Relative port 3 is covered by BAUDRATE.ASM
  8. ;
  9. ; It does the following:
  10. ;
  11. ; Displays a menu of baud rates on the screen and asks for
  12. ; your choice of baud rate.
  13. ; After pressing the key of your choice, the program will
  14. ; initialize the desired port to the desired baud rate.
  15. ;
  16. ; General EQU's
  17. ;
  18. tpa    equ    100h
  19. bdos    equ    5
  20. print    equ    9
  21. getch    equ    1
  22. cr    equ    0dh
  23. lf    equ    0ah
  24. cls    equ    26    ;your clear-screen byte
  25. ;
  26. ; Interfacer 4 equates (the necessary ones only)
  27. ;
  28. base    equ    10h    ;base port address
  29. mode    equ    base+2    ;mode port
  30. select    equ    base+7
  31. offset    equ    4    ;offset rel -> abs
  32. modem    equ    offset+2    ;modem port
  33. aux    equ    offset+1    ;auxiliary port
  34. mode1    equ    6eh    ;mode1 byte
  35. mode2    equ    70h    ;mode2 byte less baud rate
  36. ;
  37.     org    tpa
  38. ;
  39. start:    lxi    h,0
  40.     dad    sp
  41.     shld    stksave    ;save stack
  42.     lxi    sp,stack
  43.     lxi    d,menu
  44. tryagn:    mvi    c,print
  45.     call    bdos
  46.     mvi    c,getch
  47.     call    bdos
  48.     call    ucase
  49.     cpi    'A'
  50.     jc    error
  51.     cpi    'Q'
  52.     jnc    error
  53.     sui    10h    ;make range '1'..'?'
  54.     sta    p1
  55. ;
  56. ; now, ask for port
  57. ;
  58. inv:    lxi    d,which
  59.     mvi    c,print
  60.     call    bdos
  61.     mvi    c,getch
  62.     call    bdos
  63.     call    ucase
  64.     cpi    'A'
  65.     mvi    b,aux
  66.     jz    setusart
  67.     cpi    'M'
  68.     jnz    inv
  69.     mvi    b,modem
  70. ;
  71. ; now, the USART has to be initialized...
  72. ;
  73. setusart:
  74.     mov    a,b
  75.     out    select
  76.     mvi    a,mode1
  77.     out    mode
  78.     mvi    b,mode2
  79.     lda    p1        ;get baud rate
  80.     ani    0fh        ;strip high nybble
  81.     dcr    a
  82.     ora    b        ;finish mode2
  83.     out    mode        ;done!
  84. ;
  85.     lhld    stksave        ;get CP/M stack back
  86.     sphl
  87.     ret
  88. ;
  89. ; ucase routine
  90. ;
  91. ucase:    cpi    'a'
  92.     rc
  93.     sui    20h
  94.     ret
  95. ;
  96. ; Come here in case of error
  97. ;
  98. error:    lxi    d,ermenu
  99.     jmp    tryagn
  100. ;
  101. ; setterm - terminal init string
  102. ;
  103. ; this is the baud rate menu
  104. ;
  105. ermenu:    db    7,7,7,7,7,7,7
  106. menu:    db    cls,cr,lf
  107.     db    'Press  To change to baud rate:',cr,lf
  108.     db    '  A       50',cr,lf
  109.     db    '  B       75',cr,lf
  110.     db    '  C      110',cr,lf
  111.     db    '  D      135',cr,lf
  112.     db    '  E      150',cr,lf
  113.     db    '  F      300',cr,lf
  114.     db    '  G      600',cr,lf
  115.     db    '  H     1200',cr,lf
  116.     db    '  I     1800',cr,lf
  117.     db    '  J     2000',cr,lf
  118.     db    '  K     2400',cr,lf
  119.     db    '  L     3600',cr,lf
  120.     db    '  M     4800',cr,lf
  121.     db    '  N     7200',cr,lf
  122.     db    '  O     9600',cr,lf
  123.     db    '  P    19200',cr,lf,lf,lf
  124.     db    'Your choice : $'
  125. ;
  126. which:    db    cr,lf
  127.     db    'Press A for AUX port, or',cr,lf
  128.     db    'press M for MODEM port :$'
  129. ;
  130. p1:    db    0
  131. ;
  132. stksave:dw    0
  133.     ds    50
  134. stack:    equ    $
  135.     end
  136.     'Press A for AUX port,