home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / PJ8_3.ZIP / LNKTBL5.ASM < prev    next >
Assembly Source File  |  1990-02-26  |  906b  |  56 lines

  1.     title    listing five
  2.     include    asm.inc
  3.     .stack
  4.     .data
  5. one    db    'one$'
  6. two    db    'two$'
  7. three    db    'three$'
  8.  
  9. table   macro p1,p2
  10.     _TABLE segment
  11.         dw      p1
  12.     _TABLE ends
  13.         dw      p2
  14.         endm
  15.  
  16. _TABLE segment word public 'DATA'
  17. search_keys    label word
  18. _TABLE ends
  19. DGROUP    group    _TABLE
  20.     
  21. table_offsets    label word
  22.     table    1, one
  23.     table    2, two
  24.     table    3, three
  25.  
  26.     .code
  27.  
  28. ;;    main
  29. ;
  30. main    proc
  31.     mov    ax,@data
  32.     mov    ds,ax
  33.     mov    es,ax
  34.     mov    ss,ax
  35.     mov    sp,offset stack
  36.     mov    bp,0
  37.  
  38.     mov    ax,2            ; search for 2 in search_keys
  39.     mov    cx,3            ;  (table has 3 entries)
  40.     lea    di,search_keys
  41.     repne    scasw
  42.     jne    mai1            ;  if not found
  43.  
  44.     sub    di,offset search_keys    ; get corresponding offset from table
  45.     lea    si,[di-size search_keys]
  46.     mov    dx,table_offsets[bp+si]
  47.  
  48.     mov    ah,9            ; display matching string on console
  49.     int    21h
  50.  
  51. mai1:    mov    ax,4C00h
  52.     int    21h
  53. main    endp
  54.  
  55.     end    main
  56.