home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / lambda / soundpot / a / anycodkp.lbr / ANYCODKP.AZM / ANYCODKP.ASM
Encoding:
Assembly Source File  |  1993-10-26  |  3.3 KB  |  111 lines

  1.  
  2. ; ANYCODKP.ASM - A modified version of ANYCODE.  The 
  3. ;        original version was too long to fit in
  4. ;        the space remaining in the MORPAT area
  5. ;        of the modified WORDSTAR supplied with
  6. ;        the Kaypro.  This version is 16 bytes
  7. ;        shorter, but is identical in operation.
  8. ;        Replaced code is commented out, and 
  9. ;        substituted code is in capitals.  
  10. ;
  11. ;        O. V. Gray - 6 Feb 85
  12. ;
  13. ; ANYCODE.ASM - A program to allow printer codes to be
  14. ;        transmitted to EPSON or other dot matrix
  15. ;        printer from within WordStar text.
  16. ;
  17. ;        Author:  D. M. Hurst
  18. ;        Date:    March 3, 1984
  19. ;
  20. ;    ORG    02BBh    ;WS 2.26/3.0 (02DEh) WS 3.3 (02BBh)
  21. ;
  22.     ORG    02D7H    ;TO FIT IN SPACE REMAINING IN 
  23.             ;MORPAT AREA OF WORDSTAR SUPPLIED
  24.             ;WITH KAYPRO
  25.  
  26. mysub:    cpi    '`'    ;is it a code character?
  27.             ;you may sub " ` " if you use the
  28.             ;" ` " often in your text
  29. ;    jnz    ncheck    ;no, so    next check
  30.     DW    0920H    ;JR NZ,NCHECK - Z80 RELATIVE JUMP
  31. STORE:            ;ADD NEW LABEL
  32.     sta    lead    ;yes, so store temporarily
  33.     mvi    a,1    ;get a 1 in accumulator
  34.     sta    fl    ;set fl    flag
  35.     ret        ;get another character
  36.             ;without printing
  37. ncheck:    cpi    '~'    ;is it other code character?
  38. ;    jnz    hcheck    ;no, so    check if part of
  39.             ;code sequence
  40.     DW    0720H    ;JR NZ,HCHECK
  41. ;
  42. ;    sta    lead    ;yes so    store temporarily
  43. ;    mvi    a,1    ;get a 1 in accumulator
  44. ;    sta    fl    ;set fl    flag
  45. ;
  46.     CALL    STORE    ;REPLACES PREVIOUS 3 LINES
  47. ;
  48.     mvi    a,1bh    ;~ means escape required so
  49. ;    jmp    pout    ;send it.
  50.     DW    4F18H    ;JR POUT
  51. hcheck:    mov    b,a    ;set input char aside
  52.     lda    lead    ;get contents of lead
  53.     cpi    '`'    ;are we    in a code seq?
  54.     mov    a,b    ;char back in accumulator
  55. ;    jz    flchk    ;yes, so check if flag set
  56.     DW    0B28H    ;JR Z,FLCHK
  57.     mov    b,a    ;no, so    char back to b
  58.     lda    lead    ;check lead again
  59.     cpi    '~'    ;are we    in a code seq?
  60.     mov    a,b    ;char back in accumulator
  61. ;    jz    flchk    ;yes, so check if flag set    
  62.     DW    0228H    ;JR Z,FLCHK
  63. ;    jmp    pout    ;no, so    print char normally
  64.     DW    3B18H    ;JR POUT
  65. flchk:    mov    b,a    ;set char aside again
  66.     lda    fl    ;get fl    flag
  67.     cpi    00h    ;1 if set set
  68.     mov    a,b    ;char back in accumulator
  69. ;    jz    addsnd    ;not set, so last char in seq
  70.     DW    1A28H    ;JR Z,ADDSND
  71.     mov    b,a    ;yes, so set char aside again        
  72.     mvi    a,00h    ;no, so    place 00h in accumulator
  73.     sta    fl    ;and lower the flag
  74.     mov    a,b    ;char back in accumulator    
  75.     cpi    39h    ;is code char a letter?
  76.     jm    nolet1    ;no, so never mind
  77.     sui    07h    ;yes, so make it a number
  78. nolet1:    sui    30h    ;now down it form ASCII
  79.     rlc        ;first char in code so
  80.     rlc        ;move 4    low bits to high
  81.     rlc
  82.     rlc
  83.     ani    0f0h    ;0 4 lower bits
  84.     sta    first    ;store it
  85.     ret        ;go get    second char code
  86. addsnd:    mov    b,a    ;set 2nd code char aside
  87.     mvi    a,00    ;0 the accumulator
  88.     lxi    h,lead    ;get lead addr pointer in hl
  89.     mov    m,a    ;0 out the lead
  90.     inx    h    ;up the    hl
  91.     mov    m,a    ;also 0    the flag
  92.     mov    a,b    ;get char back
  93.     cpi    39h    ;was 2nd code char a letter?
  94.     jm    nolet2    ;so so skip it
  95.     sui    07h    ;yes so    make it a number
  96. nolet2:    sui    30h    ;now down either from ASCII
  97.     lxi    h,first    ;point to first code char addr
  98.     mov    b,m    ;move actual char to b
  99.     add    b    ;add a to b (result in a)
  100. pout:    mvi    c,5    ;print full code char
  101.     mov    e,a
  102.     call    5
  103.     ret        ;back for next real char
  104. ;
  105. lead    ds    1    ;space for lead code
  106. fl    ds    1    ;flag space
  107. first    ds    1    ;store first code while
  108.             ;waiting for 2nd to pro-
  109.             ;cess.
  110.     end
  111.