home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / TASMSWAN.ZIP / TRM.ASM < prev    next >
Assembly Source File  |  1989-07-17  |  2KB  |  103 lines

  1. %TITLE  "Terminal Emulator with control-code debugging"
  2.  
  3.     IDEAL
  4.     DOSSEG
  5.     MODEL    small
  6.     STACK    1024
  7.  
  8. ;--------- from AYSNCH.obj
  9.     EXTRN    ComPort:abs
  10.  
  11. cr        EQU     13
  12. lf        EQU    10
  13. bd9600        EQU    0e3h
  14. ExitKey        EQU    100
  15.  
  16.     DATASEG
  17.  
  18. exitCode    db    0
  19. welcome        db    cr,lf,'Terminal Emulator by Tom Swan',cr,lf
  20.         db    cr,lf,'Configured for 9600 baud.'
  21.         db    cr,lf,'Displays control codes in brackets for debugging'
  22.         db    cr,lf,'an RS232 serial line.'
  23.         db    cr,lf,'>>>>  Press F10 to exit <<<<',cr,lf,lf,0
  24. string        db    80 DUP (?)
  25.  
  26.     CODESEG
  27.  
  28. ;--------- from ASYNCH.obj
  29.     EXTRN    AsynchInit:proc, AsynchStop:proc, AsynchStat:proc
  30.     EXTRN    AsynchOut:proc, AsynchIn:proc, AsynchInStat:proc
  31. ;--------- from KEYBOARD.obj
  32.     EXTRN    KeyWaiting:proc, GetCh:proc
  33. ;--------- from BINASC.obj
  34.     EXTRN    BinToAscDec:proc
  35. ;--------- from STRIO.obj
  36.     EXTRN    StrWrite:proc
  37.  
  38. Start:
  39.     mov    ax,@data
  40.     mov    ds,ax
  41.     mov    es,ax
  42.     mov    di, offset welcome
  43.     call    StrWrite
  44.     mov    ah,0
  45.     mov    al,bd9600
  46.     mov    dx,ComPort
  47.     int    14h
  48.     call    AsynchInit
  49. Emulate:
  50.     call    AsynchInStat
  51.     or    dx,dx
  52.     jz    @@10
  53.     call    AsynchIn
  54.     call    DispChar
  55.     jmp    Emulate
  56. @@10:
  57.     call    KeyWaiting
  58.     jz    Emulate
  59.     call    GetCh
  60.     jnz    @@20
  61.     cmp    al,ExitKey
  62.     je    Exit
  63. @@20:
  64.     call    AsynchOut
  65.     jmp    Emulate
  66. Exit:
  67.     call    AsynchStop
  68.     mov    ah,04Ch
  69.     mov    al,[exitCode]
  70.     int    21h
  71.  
  72. %NEWPAGE
  73. ;------------------------------------------------------------------------
  74. ; DispChar/OneChar  - display any ASCII value
  75. ;------------------------------------------------------------------------
  76. ;    Input:   al = ASCII value (0...255)
  77. ;    Output:  none
  78. ;        NOTE:  control codes are displayed as [13], [10], etc
  79. ;            for debugging a serial I/O line.
  80. ;       Registers:  ax,cx,dl,di
  81. ;------------------------------------------------------------------------
  82. PROC    DispChar
  83.     cmp    al,32
  84.     jae     OneChar
  85.     xor    ah,ah
  86.     mov    cx,1
  87.     mov    di, offset string
  88.     call    BinToAscDec
  89.     mov    al, '['
  90.     call    OneChar
  91.     call    StrWrite
  92.     mov    al, ']'
  93. PROC    OneChar
  94.     mov    dl,al
  95.     mov    ah,2
  96.     int    21h
  97.     ret
  98. ENDP    OneChar
  99.  
  100. ENDP    DispChar
  101.  
  102.     END    Start
  103.