home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / DOS_HELP / ADVMSDOS.ZIP / CLINK.ASM < prev    next >
Encoding:
Assembly Source File  |  1986-06-19  |  3.3 KB  |  140 lines

  1.          name      clink
  2.          page      55,132
  3.          title     CLINK  Load and Link Graphics Characters
  4.  
  5. ;
  6. ; CLINK - Load and Link Graphics Character Table
  7. ;
  8. ; Copyright 1982, 1986 by Ray Duncan
  9. ;
  10. ; The IBM PC allows the user to define the meanings of the
  11. ; characters in the range 80H-FFH in the graphics modes, by
  12. ; pointing the vector for Int 1FH to a bit table.
  13. ;
  14. ; This program takes a filename from the command line, 
  15. ; reads a 1024 byte character bit table into memory,
  16. ; points the Int 1FH vector to the bit table, and then
  17. ; performs a "terminate and stay resident" with a return
  18. ; code of 0.  If the character table cannot be found,
  19. ; or is not at least 1024 bytes long, the program aborts
  20. ; with a return code of 1.
  21. ;
  22. ; To assemble, link, and convert this program into 
  23. ; a COM file, follow these steps:
  24. ;
  25. ;    C>MASM CLINK;
  26. ;     C>LINK CLINK;
  27. ;    C>EXE2BIN CLINK.EXE CLINK.COM
  28. ;    C>DEL CLINK.EXE
  29. ;
  30. ; Ignore the message "Warning: no stack segment" from the Linker.
  31. ;
  32.  
  33. fcb     equ      05ch              ;default file control block
  34.  
  35. cr      equ       0dh            ;ASCII carriage return
  36. lf     equ     0ah            ;ASCII line feed
  37.  
  38. stdin    equ    0            ;standard input device
  39. stdout    equ    1            ;standard output device
  40. stderr    equ    2            ;standard error device
  41.  
  42.  
  43. cseg     segment    para public 'CODE'
  44.  
  45.     assume    cs:cseg,ds:cseg,es:cseg,ss:cseg
  46.  
  47.     org       100h
  48.  
  49.  
  50. clink     proc    near            ;entry from PC-DOS
  51.  
  52.     mov    dx,offset msg1        ;sign on message
  53.     mov    cx,offset msg1_len
  54.     mov    bx,stdout
  55.     mov    ah,40h
  56.     int    21h
  57.  
  58.     mov    bx,offset fcb
  59.     mov    byte ptr [bx+9],'C'    ;force extension to .CHR
  60.     mov    byte ptr [bx+0ah],'H'
  61.     mov    byte ptr [bx+0bh],'R'
  62.  
  63.     mov    dx,offset fcb        ;try and open char table file
  64.     mov    ah,0fh
  65.     int    21h
  66.     or    al,al
  67.     jz     clink2            ;file opened, proceed
  68.     mov    dx,offset msg2        
  69.     mov    cx,msg2_len        ;file not found
  70.  
  71. clink1:    mov    bx,stderr        ;display error message
  72.     mov    ah,40h
  73.     int    21h
  74.     mov    ax,4c01h        ;exit with retcode=1
  75.     int    21h
  76.  
  77. clink2:    mov    bx,offset fcb        ;point to file control block
  78.     mov    word ptr [bx+0eh],1024    ;set record length
  79.     mov    word ptr [bx+21h],0    ;set record number
  80.     mov    word ptr [bx+23h],0
  81.  
  82.     mov    dx,offset ctab        ;set disk transfer addr
  83.     mov    ah,1ah
  84.     int    21h
  85.  
  86.     mov    dx,offset fcb        ;read char table
  87.     mov    ah,21h
  88.     int    21h
  89.     push    ax            ;save read status
  90.     
  91.     mov    ah,10h            ;close file
  92.     int    21h
  93.  
  94.     pop    ax            ;restore read status
  95.     or    al,al
  96.     jz    clink3            ;jump, read was ok 
  97.     mov    dx,offset msg3
  98.     mov    cx,msg3_len        ;read failed, print
  99.     jmp    clink1            ;error message
  100.  
  101. clink3: mov    ax,251fh        ;set Int 1FH vector to
  102.     mov    dx,offset ctab        ;point to character table    
  103.     int    21h
  104.  
  105.     mov    dx,offset msg4        ;print success message
  106.     mov    cx,msg4_len
  107.     mov    bx,stdout
  108.     mov    ah,40h
  109.     int    21h
  110.  
  111.                     ;terminate and stay resident
  112.     mov    dx,((ctab_end-clink)/16)+11h
  113.     mov    ax,3100h        ;with retcode of zero
  114.     int    21h
  115.  
  116.  
  117. msg1    db    cr,lf,'Character Set Loader for IBM PC'
  118.     db    cr,lf,'Copyright (C) 1982, 1986 Ray Duncan'
  119.     db    cr,lf,lf
  120. msg1_len equ $-msg1
  121.  
  122. msg2      db       'No such file.',cr,lf
  123. msg2_len equ $-msg2
  124.  
  125. msg3    db    'Incomplete or empty file.',cr,lf
  126. msg3_len equ $-msg3
  127.  
  128. msg4    db    'Character table loaded.',cr,lf
  129. msg4_len equ $-msg4
  130.  
  131. ctab    db    1024 dup (?)
  132.  
  133. ctab_end equ $
  134.  
  135. clink    endp
  136.  
  137. cseg     ends
  138.  
  139.     end       clink
  140.