home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol018 / areacode.asm < prev    next >
Encoding:
Assembly Source File  |  1984-04-29  |  13.0 KB  |  372 lines

  1. ;                     AREACODE.ASM Ver 1.0
  2. ;                            as of
  3. ;                       January 2, 1981
  4. ;  AREACODE is used to display the region and state, specified 
  5. ; by  the user...very handy,  when someone leaves a area  code 
  6. ; number  on a CBBS,  but no city or state  reference.  Simple 
  7. ; enough to use,  just type AREACODE nnn<cr> (where 'nnn' is a 
  8. ; three   digit  area  code),   and  in  return,   you  get  a 
  9. ; geographical  region by city(s),  and state.  Sorry if  your 
  10. ; particular city is not represented,  and feel free to add it 
  11. ; as required...
  12. ;  This  is not the most 'elegant' search routine that I could 
  13. ; have   used  in  implementing  this  program,   but  it   is 
  14. ; fast...it's  best  described  as  a  "forward  scanning/side 
  15. ; checking  mess"...if  you  don't find it matching  on  first 
  16. ; character, drop to the next possible match...
  17. ;                          Best regards,
  18. ;                          Kelly Smith, CP/M-Net SYSOP
  19. ;                          805-527-9321 (Modem, 300 Baud)
  20. ;                          805-527-0518 (Verbal Abuse)
  21.  
  22. base    equ    0    ; CP/M system base address
  23. bdos    equ    base+5    ; BDOS entry address
  24. tbuff    equ    base+80h; temporary (command) buffer
  25.  
  26. prnstg    equ    9    ; print string (ending in '$') function
  27.  
  28. lf    equ    0ah    ; ASCII line feed
  29. cr    equ    0dh    ; ASCII carriage return
  30.  
  31.     org    base+100h
  32.  
  33.     lxi    h,0    ; make local stack, so no warm boot
  34.     dad    sp
  35.     shld    oldstk
  36.     lxi    sp,stack; old stack saved, make new stack
  37.     lxi    d,msg1    ; "Area code"
  38.     call    print$message
  39.     lxi    h,tbuff    ; point to area code length
  40.     mvi    d,0    ; clear D Reg.
  41.     mov    a,m    ; get it...
  42.     adi    1    ; adjust buffer pointer +1
  43.     mov    e,a
  44.     dad    d    ; point 1 past area code number
  45.     mvi    m,'$'    ; tag with 'end of string'
  46.     lxi    d,tbuff+1    ; check for valid entry
  47.     ldax    d    ; must be ASCII space to be correct
  48.     cpi    ' '
  49.     jz    inputok
  50.     lxi    d,msg4    ; "NOT specified"
  51.     call    print$message
  52.     jmp    exit    ; exit to CP/M now
  53. inputok:call    print$message    ; o.k., so far...print whatver was input
  54.     lxi    d,msg2    ; ", is "
  55.     call    print$message
  56.     mvi    b,0    ; clear character position counter
  57.     lxi    d,tbuff+2    ; point to area code
  58.     lxi    h,area$code$table    ; point to area code table
  59. scan:    ldax    d    ; get first character of area code for match
  60.     cmp    m    ; does it match any first character in table?
  61.     jnz    scan3    ; if no match, advance 58 characters in table
  62. scan1:    inx    d    ; bump for next area code character
  63.     inx    h    ; bump to second character in area code table
  64.     inr    b    ; bump character position counter
  65.     mov    a,b    ; has character counter gone three positions?
  66.     cpi    3
  67.     jnz    scan2    ; match next character, if not at position 3
  68.     dcx    d    ; adjust character position for subsequent match
  69.     dcx    h
  70.     ldax    d    ; get last in entered area code
  71.     cmp    m    ; match to last character in area code table?
  72.     jz    match    ; if last character matches, display region, and state
  73.     inx    d    ; no match, bump both pointers
  74.     inx    h
  75. scan2:    ldax    d    ; get next character to match
  76.     cmp    m    ; any match yet?
  77.     jnz    backup    ; back-up, if no match on current position
  78.     mov    a,b    ; are we at final character position?
  79.     cpi    3
  80.     jz    match    ; if so, we have final match
  81.     jmp    scan    ; not final position, try again...
  82. backup:    dcx    d    ; back-up to start of entered area code
  83.     dcx    h    ; back-up to start of current area code in table
  84.     dcr    b    ; de-bump character position counter
  85.     jnz    backup    ; loop until we are at start of string
  86. scan3:    push    d    ; save pointer to entered area code
  87.     lxi    d,58    ; make 58 character bias
  88.     dad    d    ; add bias to area code table pointer
  89.     pop    d    ; recover pointer to entered area code
  90.     mov    a,m    ; have we hit "EOF" in area code table column?
  91.     cpi    'Z'-40h
  92.     jnz    scan    ; if not, try next string for a match...
  93. nomatch:lxi    d,msg3    ; "NOT a valid area code"
  94.     call    print$message
  95.     jmp    exit    ; exit to CP/M now...
  96. match:    inx    h    ; bump for region and state table location
  97.     xchg        ; swap to D&E Regs.
  98.     call    print$message
  99. exit:    lxi    d,crlf    ; keep it neat...
  100.     call    print$message
  101.     lhld    oldstk    ; get old CP/M stack
  102.     sphl        ; restore stack pointer, so no warm boot
  103.     ret        ; return to CP/M...
  104. ;
  105. print$message        ; print message string
  106. ;
  107.     mvi    c,prnstg; print string (until '$') function
  108.     call    bdos
  109.     ret
  110. ;
  111. area$code$table:    ; storage for area code, region, state
  112. ;
  113.     db    '205'
  114.     db    ' all regions, Alabama                                 $'
  115.     db    '907'
  116.     db    ' all regions, Alaska                                  $'
  117.     db    '602'
  118.     db    ' all regions, Arizona                                 $'
  119.     db    '213'
  120.     db    ' Los Angeles, California                              $'
  121.     db    '805'
  122.     db    ' Bakersfield, Ventura and Simi Valley, California     $'
  123.     db    '707'
  124.     db    ' Eureka, Napa and Santa Rosa, California              $'
  125.     db    '209'
  126.     db    ' Fresno and Stockton, California                      $'
  127.     db    '415'
  128.     db    ' Oakland and San Francisco, California                $'
  129.     db    '714'
  130.     db    ' Orange and San Diego, California                     $'
  131.     db    '916'
  132.     db    ' Sacramento and South Tahoe, California               $'
  133.     db    '408'
  134.     db    ' San Jose and Sunnyvale, California                   $'
  135.     db    '519'
  136.     db    ' Ontario, Canada                                      $'
  137.     db    '514'
  138.     db    ' Montreal, Canada                                     $'
  139.     db    '705'
  140.     db    ' North Bay, Ontario, Canada                           $'
  141.     db    '807'
  142.     db    ' Ontario, Canada                                      $'
  143.     db    '613'
  144.     db    ' Ottawa, Ontario, Canada                              $'
  145.     db    '418'
  146.     db    ' Quebec, Quebec, Canada                               $'
  147.     db    '819'
  148.     db    ' Quebec, Canada                                       $'
  149.     db    '416'
  150.     db    ' Toronto and Ontario, Canada                          $'
  151.     db    '204'
  152.     db    ' Manatoba, Canada                                     $'
  153.     db    '306'
  154.     db    ' Saskatchewan, Canada                                 $'
  155.     db    '403'
  156.     db    ' Alberta, Canada                                      $'
  157.     db    '804'
  158.     db    ' British Columbia, Canada                             $'
  159.     db    '303'
  160.     db    ' all regions, Colorado                                $'
  161.     db    '203'
  162.     db    ' all regions, Connecticut                             $'
  163.     db    '302'
  164.     db    ' all regions, Deleware                                $'
  165.     db    '202'
  166.     db    ' Washington, District of Columbia                     $'
  167.     db    '813'
  168.     db    ' Avon Park, Fort Myers and Winter Haven, Florida      $'
  169.     db    '305'
  170.     db    ' Fort Lauderdale, Key West, Miami and Florida         $'
  171.     db    '904'
  172.     db    ' Jacksonville, Florida                                $'
  173.     db    '404'
  174.     db    ' Atlanta, Rome, Georgia                               $'
  175.     db    '912'
  176.     db    ' Waycross, Georgia                                    $'
  177.     db    '808'
  178.     db    ' all regions, Hawaii                                  $'
  179.     db    '208'
  180.     db    ' all regions, Idaho                                   $'
  181.     db    '618'
  182.     db    ' Alton and Mount Vernon, Illinois                     $'
  183.     db    '312'
  184.     db    ' Aurora, Chicago, Elgin and Highland Park, Illinois   $'
  185.     db    '217'
  186.     db    ' Casey and Springfield, Illinois                      $'
  187.     db    '815'
  188.     db    ' La Salle, Joliet and Rockford, Illinois              $'
  189.     db    '812'
  190.     db    ' Evansville, Indiana                                  $'
  191.     db    '219'
  192.     db    ' Gary, Hammond, Michigan City and South Bend, Indiana $'
  193.     db    '317'
  194.     db    ' Indianapolis and Kokomo, Indiana                     $'
  195.     db    '712'
  196.     db    ' Council Bluffs, Iowa                                 $'
  197.     db    '515'
  198.     db    ' Des Moines and Mason City, Iowa                      $'
  199.     db    '319'
  200.     db    ' Dubuque, Iowa                                        $'
  201.     db    '316'
  202.     db    ' Dodge City and Wichita, Kansas                       $'
  203.     db    '913'
  204.     db    ' Ottawa and Topeka, Kansas                            $'
  205.     db    '606'
  206.     db    ' Ashland and Winchester, Kentuckey                    $'
  207.     db    '502'
  208.     db    ' Louiseville, Paducah and Shelbyville, Kentuckey      $'
  209.     db    '504'
  210.     db    ' Baton Rouge and New Orleans, Louisiana               $'
  211.     db    '318'
  212.     db    ' Lake Charles, Louisiana                              $'
  213.     db    '207'
  214.     db    ' all regions, Maine                                   $'
  215.     db    '301'
  216.     db    ' all regions, Maryland                                $'
  217.     db    '617'
  218.     db    ' Boston, Framingham and New Bedford, Massachusetts    $'
  219.     db    '413'
  220.     db    ' Springfield, Massachusetts                           $'
  221.     db    '905'
  222.     db    ' Mexico City, Mexico                                  $'
  223.     db    '903'
  224.     db    ' Northwest Mexico                                     $'
  225.     db    '313'
  226.     db    ' Adrian and Ann Arbor, Michigan                       $'
  227.     db    '616'
  228.     db    ' Battle Creek, Cadillac and Grand Rapids, Michigan    $'
  229.     db    '517'
  230.     db    ' Lancing and Saginaw, Michigan                        $'
  231.     db    '906'
  232.     db    ' Sault Ste. Marie, Michigan                           $'
  233.     db    '507'
  234.     db    ' Albert Lea and Rochester, Minnesota                  $'
  235.     db    '218'
  236.     db    ' Duluth, Minnesota                                    $'
  237.     db    '612'
  238.     db    ' Minneapolis and Saint Paul, Minnesota                $'
  239.     db    '601'
  240.     db    ' all regions, Mississippi                             $'
  241.     db    '417'
  242.     db    ' Joplin and Springfiled, Missouri                     $'
  243.     db    '816'
  244.     db    ' Kansas City and Saint Joseph, Missouri               $'
  245.     db    '314'
  246.     db    ' Saint Louis, Missouri                                $'
  247.     db    '406'
  248.     db    ' all regions, Montana                                 $'
  249.     db    '402'
  250.     db    ' Lincoln and Omaha, Nebraska                          $'
  251.     db    '308'
  252.     db    ' North Platte, Nebraska                               $'
  253.     db    '702'
  254.     db    ' all regions, Nevada                                  $'
  255.     db    '603'
  256.     db    ' all regions, New Hampshire                           $'
  257.     db    '609'
  258.     db    ' Atlantic City, Camden and Trenton, New Jersey        $'
  259.     db    '201'
  260.     db    ' Hackensack, Morristown and Newark, New Jersey        $'
  261.     db    '505'
  262.     db    ' all regions, New Mexico                              $'
  263.     db    '518'
  264.     db    ' Albany, Greenwich and Schenectady, New York          $'
  265.     db    '716'
  266.     db    ' Buffalo, Niagra Falls and Rochester, New York        $'
  267.     db    '607'
  268.     db    ' Elmira and Stamford, New York                        $'
  269.     db    '516'
  270.     db    ' Hempstead, New York                                  $'
  271.     db    '914'
  272.     db    ' Monroe, Mount Vernon and Poughkeepsie, New York      $'
  273.     db    '212'
  274.     db    ' New York City, New York                              $'
  275.     db    '315'
  276.     db    ' Syracuse and Utica, New York                         $'
  277.     db    '704'
  278.     db    ' Charlotte and Salisbury, North Carolina              $'
  279.     db    '919'
  280.     db    ' Greenville and Williamston, North Carolina           $'
  281.     db    '701'
  282.     db    ' all regions, North Dakota                            $'
  283.     db    '216'
  284.     db    ' Akron, Cleveland, Massilon and Youngstown, Ohio      $'
  285.     db    '513'
  286.     db    ' Cincinnati and Dayton, Ohio                          $'
  287.     db    '614'
  288.     db    ' Columbus, Marietta and Newark, Ohio                  $'
  289.     db    '419'
  290.     db    ' Toldeo, Ohio                                         $'
  291.     db    '918'
  292.     db    ' Muskogee and Tulsa, Oklahoma                         $'
  293.     db    '405'
  294.     db    ' Oklahoma City, Oklahoma                              $'
  295.     db    '503'
  296.     db    ' all regions, Oregon                                  $'
  297.     db    '215'
  298.     db    ' Allentown, Chester and Philadelphia, Pennsylvania    $'
  299.     db    '814'
  300.     db    ' Altoona, Erie and Punxsutawney, Pennsylvania         $'
  301.     db    '717'
  302.     db    ' Harrisburg, Scranton and Wilkes-Barre, Pennsylvania  $'
  303.     db    '809'
  304.     db    ' all regions, Puerto Rico                             $'
  305.     db    '401'
  306.     db    ' all regions, Rhode Island                            $'
  307.     db    '803'
  308.     db    ' all regions, South Carolina                          $'
  309.     db    '605'
  310.     db    ' all regions, South Dakota                            $'
  311.     db    '615'
  312.     db    ' Chattanooga and Nashville, Tennessee                 $'
  313.     db    '901'
  314.     db    ' Memphis, Tennesee                                    $'
  315.     db    '806'
  316.     db    ' Amarillo, Texas                                      $'
  317.     db    '512'
  318.     db    ' Austin, Corpus Christi and San Antonio, Texas        $'
  319.     db    '214'
  320.     db    ' Dallas, Texas                                        $'
  321.     db    '713'
  322.     db    ' Galveston and Houston, Texas                         $'
  323.     db    '817'
  324.     db    ' Temple, Texas                                        $'
  325.     db    '801'
  326.     db    ' all regions, Utah                                    $'
  327.     db    '802'
  328.     db    ' all regions, Vermont                                 $'
  329.     db    '809'
  330.     db    ' all regions, Virgin Islands                          $'
  331.     db    '804'
  332.     db    ' Charlottesville, Norfolk and Richmond, Virginia      $'
  333.     db    '703'
  334.     db    ' Fredericksburg, Roanoke and Winchester, Virginia     $'
  335.     db    '509'
  336.     db    ' Pullman, Walla Walla, Washington                     $'
  337.     db    '206'
  338.     db    ' Seattle and Vancouver, Washington                    $'
  339.     db    '304'
  340.     db    ' all regions, West Virginia                           $'
  341.     db    '608'
  342.     db    ' Beloit and Madison, Wisconsin                        $'
  343.     db    '715'
  344.     db    ' Eau Claire and Wausau, Wisconsin                     $'
  345.     db    '414'
  346.     db    ' Green Bay, Milwaukee and Racine, Wisconsin           $'
  347.     db    '307'
  348.     db    ' all regions, Wyoming                                 $'
  349.     db    'Z'-40h    ; "EOF"
  350.     db    'Z'-40h    ; "EOF"
  351.     db    'Z'-40h    ; "EOF"
  352. ;
  353. msg1:    db    cr,lf,' Area code$'
  354. msg2:    db    ', is$'
  355. msg3:    db    ' NOT a valid area code!$'
  356. msg4:    db    ' NOT specified!$'
  357. crlf:    db    cr,lf,'$'
  358. ;
  359. oldstk:    ds    2    ; storage for "old" CP/M stack pointer
  360.     ds    16    ; storage for "local" stack
  361. stack    equ    $    ; "local" stack pointer starts here
  362. ;
  363.     end
  364.