home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol202 / anycode.asm < prev    next >
Encoding:
Assembly Source File  |  1984-12-19  |  2.4 KB  |  84 lines

  1.  
  2. ; ANYCODE.ASM - A program to allow printer codes to be 
  3. ;            transmitted to EPSON or other dot matrix 
  4. ;            printer from within WordStar text.
  5. ;
  6. ;        Author:  D. M. Hurst
  7. ;        Date:    March 3, 1984
  8. ;
  9.     ORG    02BBh    ;WS 2.26/3.0 (02DEh) WS 3.3 (02BBh)
  10. ;
  11. mysub:    cpi    '`'    ;is it a code character?
  12.                         ;you may sub " ` " if you use the
  13.                         ;" ` " often in your text 
  14.     jnz    ncheck    ;no, so next check
  15.     sta    lead    ;yes, so store temporarily
  16.     mvi    a,1    ;get a 1 in accumulator
  17.     sta    fl    ;set fl flag
  18.     ret        ;get another character
  19.             ;without printing
  20. ncheck: cpi    '~'    ;is it other code character?
  21.     jnz    hcheck    ;no, so check if part of
  22.             ;code sequence
  23.     sta    lead    ;yes so store temporarily 
  24.     mvi    a,1    ;get a 1 in accumulator
  25.     sta    fl    ;set fl flag
  26.     mvi    a,1bh    ;~ means escape required so 
  27.     jmp    pout    ;send it.
  28. hcheck: mov    b,a    ;set input char aside
  29.     lda    lead    ;get contents of lead
  30.     cpi    '`'    ;are we in a code seq?
  31.     mov    a,b    ;char back in accumulator
  32.     jz    flchk    ;yes, so check if flag set
  33.     mov    b,a    ;no, so char back to b
  34.     lda    lead    ;check lead again
  35.     cpi    '~'    ;are we in a code seq?
  36.     mov    a,b    ;char back in accumulator
  37.     jz    flchk    ;yes, so check if flag set    
  38.     jmp    pout    ;no, so print char normally
  39. flchk:    mov    b,a    ;set char aside again
  40.     lda    fl    ;get fl flag
  41.     cpi    00h    ;1 if set set
  42.     mov    a,b    ;char back in accumulator
  43.     jz    addsnd    ;not set, so last char in seq
  44.     mov    b,a    ;yes, so set char aside again        
  45.     mvi    a,00h    ;no, so place 00h in accumulator
  46.     sta    fl    ;and lower the flag
  47.     mov    a,b    ;char back in accumulator    
  48.         cpi    39h    ;is code char a letter?
  49.         jm    nolet1  ;no, so never mind 
  50.         sui    07h    ;yes, so make it a number
  51. nolet1:    sui    30h    ;now down it form ASCII
  52.     rlc        ;first char in code so 
  53.     rlc        ;move 4 low bits to high
  54.     rlc
  55.     rlc
  56.     ani    0f0h    ;0 4 lower bits
  57.     sta    first    ;store it
  58.     ret        ;go get second char code
  59. addsnd:    mov    b,a    ;set 2nd code char aside
  60.     mvi    a,00    ;0 the accumulator
  61.     lxi    h,lead    ;get lead addr pointer in hl
  62.     mov    m,a    ;0 out the lead
  63.     inx    h    ;up the hl
  64.     mov    m,a    ;also 0 the flag
  65.     mov    a,b    ;get char back
  66.     cpi    39h    ;was 2nd code char a letter?
  67.     jm    nolet2    ;so so skip it
  68.     sui    07h    ;yes so make it a number
  69. nolet2:    sui    30h    ;now down either from ASCII
  70.     lxi    h,first    ;point to first code char addr
  71.     mov    b,m    ;move actual char to b
  72.     add    b    ;add a to b (result in a)
  73. pout:    mvi    c,5    ;print full code char
  74.     mov    e,a
  75.     call    5
  76.     ret        ;back for next real char
  77. ;
  78. lead    ds    1    ;space for lead code
  79. fl    ds    1    ;flag space
  80. first    ds    1    ;store first code while
  81.             ;waiting for 2nd to pro-
  82.             ;cess.
  83.     end
  84.