Phone Alphas to Numbers program PAN.8

Last Up date: 2005 October 5
From: 2004 May 6 version.

This program will convert such things as: I Fly SWA to all telephone numbers. You can redirect any file to it, but that is not very useful.

To exit a filter program like PAN which will accept a line at a time from the keyboard you have to: Press F6 or Ctrl-Break, possibly Ctrl-C will work.

Some Details about PAN.8

;Phone Alpha to Numbers (PAN) Mon  10-29-2001
; Cleaned a bit Wed  05-19-2004

main:   cld             ;Insure Lo to Hi
        mov     dx,buf  ;[DX]=Start of Buffer
t0:     xor     bx,bx   ;BX=0 for StdIn
        mov     ch,0fd  ;Buffer below stack
        mov     ah,03f  ;DOS Read StdIn
        int     021
        mov     cx,ax   ;CX=number bytes read
        jcxz    ret     ;Stop if zero
        mov     si,dx
        mov     di,dx
        mov     bl,tt-'A'   ;Start at A
t1:     lodsb           ;Get user byte
        and     al,05f  ;Force to upper case
        cmp     al,'A'  ;Keep symbols etc.
        jb      >t3     ; just step over
        xlatb
        stosb           ;plant new value
t2:     loop    t1
        mov     bl,1    ;StdOut
        mov     cx,di   ;CX=last
        sub     cx,dx   ;CX=Number of bytes
        mov     ah,040  ;DOS Write StdOut
        int     021
        cmp     ax,cx   ;Test OK write
        je      t0
        ret
t3:     inc     di      ;skip across
        jmp     t2

tt:     db      '22233344455566677778889999'
        db      '[\]^_' ;Chars > Z
buf:
Setting CH to FD insures there is some space for the stack at the top of memory.

The hardware uses a translate table that is 256 bytes long. The coding insures that bytes whose values is less than an upper case "A" will not be translated. Hence, the translate table below "A" can have garbage in it, or in this case part of the program! Further, the and al,05f forces lower case letters to upper case. And: Insures the upper part of the translate table will not be used.

In A86 a label that is a single letter followed by a number is a "local" label and can be used several times in one program. Note that a forward reference to a local label is preceded by the > sign.

You will notice in a few places I move a value into BL making use of the fact that I know BH was zero. This is tricky code and could cause much confusion if the program got longer. Many would consider this bad programming. It would be safer to move values into BX, using another byte for the value. I wrote this when I was young and foolish!

Our next sample program takes parameters from the command line



Contact me at:
My phone #'s
For comments call, or e-mail me. Go to My Home Page or TOP of this page.