home *** CD-ROM | disk | FTP | other *** search
/ RBBS in a Box Volume 1 #2 / RBBS_vol1_no2.iso / add2 / suggest.zip / SUGGEST.ASM next >
Assembly Source File  |  1986-11-09  |  3KB  |  209 lines

  1. ; SUGGEST.ASM.  From PC Magazine Vol 5 No 20, November 25, 1986
  2. ; by Michael J. Mefford
  3.  
  4. code segment
  5. assume cs:code,ds:code
  6. org 100h
  7.  
  8. start:        jmp    initialize
  9.  
  10. copy_right    db    'Copyright 1986 Ziff-Davis Publishing Co.'
  11. screen_seg    dw  0b000h
  12. old_timer    dd  ?
  13. status_reg    dw  ?
  14.  
  15. counter        dw  0
  16. time_out    dw  1
  17. frequency    dw  7387h
  18.  
  19. freq_constant    equ 3276
  20. dura_constant    equ 4205
  21.  
  22. suggest:    sti
  23.         pushf
  24.         push    ax
  25.         push    cx
  26.         push    dx
  27.         push     ds
  28.         push    es
  29.         push    si
  30.         push    di
  31.  
  32.         push    cs
  33.         pop    ds
  34.         inc    word ptr counter
  35.         mov    dx,counter
  36.         cmp    dx,frequency
  37.         jnz    exit
  38.         mov    word ptr counter,0
  39.         mov    ax,40h
  40.         mov    es,ax
  41.         mov    al,es:[49h]
  42.         cmp    al,1
  43.         jbe    exit
  44.         cmp    al,3
  45.         jbe    display
  46.         cmp    al,7
  47.         jnz    exit
  48.  
  49. display:    mov    dx,status_reg
  50.         mov    ax,screen_seg
  51.         push    ds
  52.         pop    es
  53.         mov    ds,ax
  54.         mov    si,160*11
  55.         mov    di,offset screen
  56.         cld
  57.         call    read
  58.         push    ds
  59.         push    es
  60.         pop    ds
  61.         pop    es
  62.         mov    si,offset msg
  63.         call    write
  64.  
  65.         mov    cx,time_out
  66. delay:        dec    cx
  67.         jnz    delay
  68.  
  69.         mov    si,offset screen
  70.         call    write
  71.  
  72. exit:        pop    di
  73.         pop    si
  74.         pop    es
  75.         pop    ds
  76.         pop    dx
  77.         pop    cx
  78.         pop    ax
  79.         popf
  80.  
  81.         jmp    cs:old_timer
  82.  
  83. read:        mov    cx,3*80
  84. horz_ret1:    in    al,dx
  85.         test    al,1
  86.         jnz    horz_ret1
  87.         cli
  88.  
  89. wait1:        in    al,dx
  90.         test    al,1
  91.         jz    wait1
  92.         lodsb
  93.         sti
  94.         stosb
  95.         inc    si
  96.         loop    horz_ret1
  97.         ret
  98.  
  99. write:        mov    di,160*11
  100.         mov    cx,3*80
  101. put_byte:    lodsb
  102.         mov    ah,al
  103. horz_ret2:    in    al,dx
  104.         test    al,1
  105.         jnz    horz_ret2
  106.         cli
  107.  
  108. wait2:        in    al,dx
  109.         test    al,1
  110.         jz    wait2
  111.         mov    al,ah
  112.         stosb
  113.         sti
  114.         inc    di
  115.         loop    put_byte
  116.         ret
  117.  
  118. initialize:    mov    al,32
  119.         mov    di,offset msg
  120.         mov    cx,80*3
  121.         rep    stosb
  122.  
  123. parse:        xor    cx,cx
  124.         mov    si,82h
  125.         cmp    byte ptr[si-2],1
  126.         ja    get_msg
  127.         int    20h
  128.  
  129. get_msg:    lodsb
  130.         inc    cx
  131.         cmp    al,13
  132.         jz    message
  133.         cmp    al,'/'
  134.         jnz    get_msg
  135.  
  136. get_switch:    lodsb
  137.         cmp    al,13
  138.         jz    message
  139.         and    al,5fh
  140.         cmp    al,'F'
  141.         jnz    duration
  142.         call    convert
  143.         mov    bx,freq_constant
  144.         mul    bx
  145.         sub    frequency,ax
  146.         jmp    short get_switch
  147.  
  148. duration:    cmp    al,'D'
  149.         jnz    get_switch
  150.         call    convert
  151.         mov    bx,dura_constant
  152.         mul    bx
  153.         add    time_out,ax
  154.         jmp    short get_switch
  155.  
  156. message:    mov    si,82h
  157.         mov    di,offset msg+80
  158.         dec    cx
  159.         cmp    cx,80
  160.         jb    center
  161.         mov    cx,80
  162.         jmp    short store
  163.  
  164. center:        mov    bx,80
  165.         sub    bx,cx
  166.         shr    bx,1
  167.         add    di,bx
  168. store:        rep    movsb
  169.  
  170. card:        mov    ax,40h
  171.         mov    es,ax
  172.         mov    ax,es:[63h]
  173.         add    ax,6
  174.         mov    status_reg,ax
  175.         cmp    ax,3bah
  176.         jz    interrupt
  177.         add    word ptr screen_seg,800h
  178.  
  179. interrupt:    mov    ax,351ch
  180.         int    21h
  181.         mov    word ptr old_timer,bx
  182.         mov    word ptr old_timer[2],es
  183.  
  184.         mov    dx,offset suggest
  185.         mov    ax,251ch
  186.         int    21h
  187.  
  188.         mov    dx,offset screen+80*3+1
  189.         int    27h
  190.  
  191. convert:    xor    ah,ah
  192.         lodsb
  193.         cmp    al,'1'
  194.         jb    ignore
  195.         cmp    al,'9'
  196.         ja    ignore
  197.         sub    al,30h
  198.         ret
  199. ignore:        mov    al,0
  200.         ret
  201.  
  202. msg:
  203. org    offset msg+80*3
  204. screen:
  205.  
  206. code ends
  207. end    start
  208.  
  209.