home *** CD-ROM | disk | FTP | other *** search
/ Computer Installation Guide - Dragon Clan Series / CD2.iso / TXT / T2E41 / BIND.ASM next >
Encoding:
Assembly Source File  |  1996-01-01  |  13.1 KB  |  452 lines

  1. ;-------------------------------------------------------;
  2. ;                                                       ;
  3. ;  Txt2Exe V4.00                                        ;
  4. ;      - Bind.asm  ╫╓┐Γ└ª░≤│╠╨≥                         ;
  5. ;                                                       ;
  6. ;   │╠╩╜╫≈╒▀:═⌠└±╚²   ▒ú┴⌠╦∙╙╨░µ╚¿!      1995.7         ;
  7. ;                                                       ;
  8. ;       ╥╘╧┬┤·┬δ╓╨╙╨╣╪░µ╚¿╡─╨┼╧ó▓╗╡├╨▐╕─,╥╘╧┬┤·┬δ▓╗╡├╙├ ;
  9. ;   ╙┌╔╠╥╡─┐╡─íú                                        ;
  10. ;                                                       ;
  11. ;-------------------------------------------------------;
  12.  
  13. code segment
  14.     assume cs:code,ds:code,es:code
  15.  
  16.     msgCopyright  db 'Bind V1.04 (C)Copyright by LiSan Wang. '
  17.                   db '1995.7',0dH,0aH
  18.                   db 'All rights reserved.',0dH,0aH,0aH
  19.                   db 'link cclib file to Txt2Exe. '
  20.                   db 'Use with TXT2EXE only',0dH,0aH,0aH,0
  21.     msgHelp       db 'Usage: bind  cclib_file  exe_file[.exe]',0
  22.     msgOpenError  db ' open error.',0
  23.     msgReadError  db ' read error.',0
  24.     msgWriteError db ' write error.',0
  25.     msgIsNotT2E   db ' is not a TXT2EXE file.',0
  26.     msgMemError   db 'Has not enough memory.',0
  27.     msgWarning    db 'Warning: rewrite '
  28.     msgStrend     db 0
  29.  
  30.     fnInput       db 64 dup(0)          ; ╩Σ╚δ╬─╝■├√
  31.     fnOutput      db 64 dup(0)          ; ╩Σ│÷╬─╝■├√
  32.  
  33.     handleInput   dw 0                  ; ╩Σ╚δ╬─╝■╛Σ▒·
  34.     handleOutput  dw 0                  ; ╩Σ│÷╬─╝■╛Σ▒·
  35.  
  36.     fileDate      dw 0                  ; ╬─╝■╚╒╞┌
  37.     fileTime      dw 0                  ; ╬─╝■╩▒╝Σ
  38.  
  39.     segPsp        dw 0                  ; PSP╢╬╓╡
  40.     segBuffer     dw 0                  ; ─┌▓┐╗║│σ╟°╢╬╓╡
  41.  
  42.     attrib        dw 0                  ; ╬─╝■╩⌠╨╘
  43.     position      db 32 dup(0)          ; ╬─╝■═╖╗║│σ╟°
  44.  
  45. ;-------------------------------------------------------;
  46. ; ╧╘╩╛╫╙│╠╨≥                                            ;
  47. ;       ╚δ┐┌: bx ╬¬┤²╧╘╩╛╨┼╧ó╡─╞½╥╞┴┐                   ;
  48. ;       ╢»╫≈: ╜½bx╓╕╧≥╡─╥╘0H╜ß╬▓╡─╫╓╖√┤«╘┌╞┴─╗╔╧╧╘╩╛│÷  ;
  49. ;             └┤                                        ;
  50. ;-------------------------------------------------------;
  51.  
  52.  disp proc near
  53.  @ds0:
  54.     mov         al,cs:[bx]
  55.     or          al,al
  56.     jz          @ds1
  57.     mov         ah,0eH
  58.     push        bx
  59.     mov         bl,7
  60.     int         10H
  61.     pop         bx
  62.     inc         bx
  63.     jmp         short @ds0
  64.  @ds1:
  65.     ret
  66.  disp endp
  67.  
  68. ;-------------------------------------------------------;
  69. ; │÷┤φ┤ª└φ╫╙│╠╨≥                                        ;
  70. ;       ╚δ┐┌: bx ╬¬│÷┤φ╨┼╧ó╡─╞½╥╞┴┐                     ;
  71. ;       ╢»╫≈: ╜½bx╓╕╧≥╡─│÷┤φ╨┼╧ó╘┌╞┴─╗╔╧╧╘╩╛│÷└┤,╣╪▒╒   ;
  72. ;             ╬─╝■,╩═╖┼╗║│σ╟°,╚╗║≤╖╡╗╪DOS               ;
  73. ;-------------------------------------------------------;
  74.  
  75.  error proc near
  76.     call        near ptr disp
  77.     cmp         word ptr cs:segBuffer,0
  78.     jz          @e0
  79.     mov         ah,49H
  80.     mov         es,cs:segBuffer
  81.     int         21H
  82.  @e0:
  83.     mov         ax,4cffH
  84.     int         21H
  85.  error endp
  86.  
  87. ;-------------------------------------------------------;
  88. ; ╣╪▒╒╬─╝■╫╙│╠╨≥                                        ;
  89. ;       ╢»╫≈: ╣╪▒╒╦∙╙╨┤≥┐¬╡─╬─╝■                        ;
  90. ;-------------------------------------------------------;
  91.  
  92.  close proc near
  93.     cmp          word ptr handleInput,0
  94.     jz           @c0
  95.     mov          ah,3eH
  96.     mov          bx,handleInput
  97.     int          21H
  98.  @c0:
  99.     cmp          word ptr handleOutput,0
  100.     jz           @c1
  101.     mov          ah,3eH
  102.     mov          bx,handleInput
  103.     int          21H
  104.  @c1:
  105.     ret
  106.  close endp
  107.  
  108. ;-------------------------------------------------------;
  109. ; │⌡╩╝╗»╫╙│╠╨≥╓«╥╗                                      ;
  110. ;       ╢»╫≈: ╖╓╬÷├ⁿ┴ε╨╨,▓ó╔Ω╟δ╗║│σ╟°                   ;
  111. ;-------------------------------------------------------;
  112.  
  113.  init0 proc near
  114.     mov         ax,cs
  115.     mov         es,ax
  116.     mov         bx,offset msgCopyright
  117.     call        near ptr disp
  118.     cmp         byte ptr ds:80H,2
  119.     jae         @i2
  120.  @i1:
  121.     mov         bx,offset msgHelp
  122.     call        near ptr error
  123.  @i2:
  124.     cld
  125.     mov         si,81H
  126.     mov         di,offset fnInput
  127.  @i3:
  128.     lodsb
  129.     cmp         al,' '
  130.     jz          @i3
  131.     cmp         al,'/'
  132.     jz          @i1
  133.     cmp         al,'?'
  134.     jz          @i1
  135.  @i4:
  136.     cmp         al,'/'
  137.     jz          @i5
  138.     cmp         al,0dH
  139.     jz          @i1
  140.     cmp         al,' '
  141.     jz          @i7
  142.     stosb
  143.     lodsb
  144.     jmp         short @i4
  145.  @i5:
  146.     lodsb
  147.     cmp         al,0dH
  148.     jz          @i1
  149.     cmp         al,' '
  150.     jnz         @i5
  151.  @i7:
  152.     lodsb
  153.     cmp         al,' '
  154.     jz          @i7
  155.     dec         si
  156.  @i8:
  157.     mov         al,0
  158.     stosb
  159.     mov         di,offset fnOutput
  160.  @i9:
  161.     lodsb
  162.     cmp         al,' '
  163.     jz          @i10
  164.     cmp         al,'/'
  165.     jz          @i10
  166.     cmp         al,0dH
  167.     jnz         @i11
  168.  @i10:
  169.     mov         al,0
  170.  @i11:
  171.     stosb
  172.     or          al,al
  173.     jnz         @i9
  174.  @i12:
  175.     mov         ax,cs
  176.     mov         ds,ax
  177.     mov         si,offset fnOutput
  178.     mov         di,si
  179.     cmp         byte ptr [si],0
  180.     jnz         @i13
  181.     jmp         @i1
  182.  @i13:
  183.     lodsb
  184.     or          al,al
  185.     jnz         @i14
  186.     mov         al,'.'
  187.  @i14:
  188.     stosb
  189.     cmp         al,'.'
  190.     jnz         @i13
  191.     cmp         byte ptr [si-2],'\'
  192.     jnz         @i15
  193.     nop
  194.     nop
  195.     jmp         @i1
  196.  @i15:
  197.     mov         al,'e'
  198.     stosb
  199.     mov         al,'x'
  200.     stosb
  201.     mov         al,'e'
  202.     stosb
  203.     mov         al,0
  204.     stosb
  205.  
  206.     mov         ah,4aH
  207.     mov         bx,zseg
  208.     sub         bx,segPsp
  209.     mov         es,segPsp
  210.     int         21H
  211.     mov         ah,48H
  212.     mov         bx,1000H
  213.     int         21H
  214.     jnc         @i16
  215.     mov         bx,offset msgMemError
  216.     call        near ptr error
  217.  @i16:
  218.     mov         segBuffer,ax
  219.     ret
  220.  init0 endp
  221.  
  222. ;-------------------------------------------------------;
  223. ; │⌡╩╝╗»╫╙│╠╨≥╓«╢■                                      ;
  224. ;       ╢»╫≈: ╢╘╩Σ╚δíó╩Σ│÷╬─╝■╜°╨╨╘ñ┤ª└φ                ;
  225. ;-------------------------------------------------------;
  226.  
  227.  init1 proc near
  228.     mov         ax,3d00H
  229.     mov         dx,offset fnInput
  230.     int         21H
  231.     jnc         @r1
  232.     mov         bx,offset fnInput
  233.  @r0:
  234.     call        near ptr disp
  235.     mov         bx,offset msgOpenError
  236.     call        near ptr error
  237.  @r1:
  238.     mov         handleInput,ax
  239.     mov         ax,3d00H
  240.     mov         dx,offset fnOutput
  241.     int         21H
  242.     jnc         @r3
  243.  @r2:
  244.     call        near ptr close
  245.     mov         bx,offset fnOutput
  246.     jmp         @r0
  247.  @r3:
  248.     mov         handleOutput,ax
  249.     mov         bx,ax
  250.     mov         ax,5700H
  251.     int         21H
  252.     mov         fileDate,dx
  253.     mov         fileTime,cx
  254.     mov         ah,3fH
  255.     mov         bx,handleOutput
  256.     mov         cx,20H
  257.     mov         dx,offset position
  258.     int         21H
  259.     jnc         @r5
  260.     call        near ptr close
  261.     mov         bx,offset fnOutput
  262.     call        near ptr disp
  263.     mov         bx,offset msgReadError
  264.     call        near ptr error
  265.  @r5:
  266.     cmp         word ptr position+10H,0100H
  267.     jz          @r7
  268.     call        near ptr close
  269.     mov         bx,offset fnOutput
  270.     call        near ptr disp
  271.     mov         bx,offset msgIsNotT2E
  272.     call        near ptr error
  273.  @r7:
  274.     mov         ax,4300H
  275.     mov         bx,handleOutput
  276.     mov         dx,offset fnOutput
  277.     int         21H
  278.     mov         attrib,cx
  279.     mov         ax,4301H
  280.     mov         bx,handleOutput
  281.     mov         cx,0
  282.     mov         dx,offset fnOutput
  283.     int         21H
  284.     mov         ax,word ptr position+4
  285.     mov         bx,512
  286.     mov         cx,word ptr position+2
  287.     cmp         cx,0
  288.     jz          @r9
  289.     dec         ax
  290.  @r9:
  291.     mul         bx
  292.     add         ax,cx
  293.     adc         dx,0
  294.     mov         word ptr position,ax
  295.     mov         word ptr position+2,dx
  296.     mov         ah,3eH
  297.     mov         bx,handleOutput
  298.     int         21H
  299.     mov         ax,3d01H
  300.     mov         dx,offset fnOutput
  301.     int         21H
  302.     jnc         @r11
  303.     jmp         @r2
  304.  @r11:
  305.     mov         handleOutput,ax
  306.     mov         bx,ax
  307.     mov         ax,4200H
  308.     mov         cx,word ptr position+2
  309.     mov         dx,word ptr position
  310.     int         21H
  311.     ret
  312.  init1 endp
  313.  
  314. ;-------------------------------------------------------;
  315. ; └ª░≤╫╙│╠╨≥                                            ;
  316. ;       ╢»╫≈: ╜½╕°╢¿╡─╫╓─ú╬─╝■╛¡╫¬╗╗║≤╙δEXE╬─╝■└ª░≤╘┌   ;
  317. ;             ╥╗╞≡                                      ;
  318. ;-------------------------------------------------------;
  319.  
  320. ;-------------------------------------------------------;
  321. ;     Bind.exe╢╘╡π╒≤╫╓┐Γ╬─╝■╙╨╥╗╢¿╡─╥¬╟≤:╩╫╧╚╩╟║║╫╓▒╪╨δ ;
  322. ; ┤╙01╟°╡╜88╟°┴¼╨°┤µ╖┼,╡½▓╗╥╗╢¿╖╟╥¬╡╜88╟°; ╞Σ┤╬╩╟├┐╕÷║║ ;
  323. ; ╫╓╡─32╫╓╜┌╡π╒≤╫╓─ú╩²╛▌▒╪╨δ╥╘╚τ╧┬╨╬╩╜┤µ╖┼:             ;
  324. ;                                                       ;
  325. ;       ╫≤░δ▓┐╖╓  ╙╥░δ▓┐╖╓                              ;
  326. ;                                                       ;
  327. ;       ╡┌0╫╓╜┌   ╡┌1╫╓╜┌                               ;
  328. ;          .         .                                  ;
  329. ;          .         .                                  ;
  330. ;          .         .                                  ;
  331. ;       ╡┌30╫╓╜┌  ╡┌31╫╓╜┌                              ;
  332. ;                                                       ;
  333. ;     ╚τ╣√╡π╒≤╫╓┐Γ╬─╝■▓╗┬·╫π╥╘╔╧┴╜╕÷╠⌡╝■,╟δ╨▐╕─▒╛╫╙│╠╨≥ ;
  334. ;                                                       ;
  335. ;     ╜≡╔╜SPDOS 6.0F╓╨╡─╝≥╨▌╡π╒≤╫╓┐Γ╬─╝■╚▒╔┘11í½14╟°,▓ó ;
  336. ; ╟╥╞Σ├┐╕÷║║╫╓╡─32╫╓╜┌╡π╒≤╫╓─ú╩²╛▌┤µ╖┼╨╬╩╜╚τ╧┬:         ;
  337. ;                                                       ;
  338. ;       ╫≤░δ▓┐╖╓  ╙╥░δ▓┐╖╓                              ;
  339. ;                                                       ;
  340. ;       ╡┌0╫╓╜┌   ╡┌16╫╓╜┌                              ;
  341. ;          .         .                                  ;
  342. ;          .         .                                  ;
  343. ;          .         .                                  ;
  344. ;       ╡┌15╫╓╜┌  ╡┌31╫╓╜┌                              ;
  345. ;                                                       ;
  346. ;     ╥≥╢°▓╗─▄╓▒╜╙╙╔Bind.exe┤ª└φíú╜≡╔╜SPDOS 6.0F╓╨╡─╖▒  ;
  347. ; ╠σ╡π╒≤╫╓┐Γ╬─╝■╚▒╔┘1í½14╟°,╥▓▓╗─▄╓▒╜╙╙╔Bind.exe┤ª└φíú  ;
  348. ;                                                       ;
  349. ;     ╞Σ╦ⁿ║║╫╓╧╡═│╡─16╡π╒≤╧╘╩╛╫╓┐Γ╬─╝■╛°┤≤▓┐╖╓╢╝┐╔╥╘╙├  ;
  350. ; Bind.exe╓▒╜╙└ª░≤╡╜╓≈│╠╨≥╔╧╚Ñíú                        ;
  351. ;                                                       ;
  352. ;     ╓╨╣·┴·ACIOSíó╧ú═√UCDOS╡╚╧╘╩╛╫╓┐Γ╬─╝■│ñ╢╚╬¬261696  ;
  353. ; ╫╓╜┌╡─║║╫╓╧╡═│,╫╓┐Γ╙δTXT2EXE╝µ╚▌                      ;
  354. ;                                                       ;
  355. ;     SPDOS 6.0F╡─╝≥╠σ╫╓┐Γ,╟δ░┤╥╘╧┬╫ó╩═╨▐╕─▒╛╘┤│╠╨≥     ;
  356. ;     ╒δ╢╘CXDOS╡─╨▐╕─╬┤╛¡╡≈╩╘                           ;
  357. ;-------------------------------------------------------;
  358.  
  359.  bind proc near
  360.     push        ds
  361.     mov         ds,segBuffer
  362.     mov         ax,ds
  363.     mov         es,ax
  364.     cld
  365.  @t1:
  366.     mov         bx,cs:handleInput
  367.     mov         ah,3fH
  368.  
  369. ; ╧┬├µ╥╗╠⌡╓╕┴ε┐╔╥╘╕∙╛▌▓╗═¼╡─║║╫╓╧╡═│╜°╨╨╨▐╕─
  370. ;    ╢╘ SPDOS 6.0F ╝≥╠σ╫╓┐Γ,╕─╬¬
  371. ;       mov    cx,10*94*32
  372. ;    ╢╘ CXDOS ╕─╬¬(CXDOS╡─╦∙╙╨╕─╢»╛∙╬┤╛¡╡≈╩╘)
  373. ;       mov    cx,10*94*32
  374.  
  375.     mov         cx,65536-64             ; ╒Γ╠⌡╓╕┴ε┐╔╥╘╚τ╔╧╨▐╕─
  376.  
  377.     mov         dx,32
  378.     int         21H
  379.  
  380. ; ╢╘SPDOS 6.0F ╝≥╠σ╫╓┐Γ,▒Ω║┼í░@t2í▒╡╜í░@t6í▒╓«╝Σ╡─╓╕┴ε╚Ñ╡⌠
  381. ; ╢╘CXDOS, ▒Ω║┼í░@t2í▒╙δí░@t3í▒╓«╝Σ╡─┴╜╠⌡╓╕┴ε╚Ñ╡⌠(╬┤╛¡╡≈╩╘)
  382.  
  383.  @t2:
  384.     cmp         ax,0
  385.     jz          @t20
  386.  @t3:
  387.     mov         dx,ax
  388.     mov         si,32
  389.     mov         di,0
  390.  @t4:
  391.     cmp         si,dx
  392.     ja          @t6
  393.     mov         cx,16
  394.  @t5:
  395.     lodsw
  396.     mov         es:[di],al
  397.     mov         es:[di+16],ah
  398.     inc         di
  399.     loop        @t5
  400.     add         di,16
  401.     jmp         @t4
  402.  @t6:
  403.     mov         ah,40H
  404.     mov         bx,cs:handleOutput
  405.     mov         cx,dx
  406.     mov         dx,0
  407.     int         21H
  408.  
  409. ; ╢╘SPDOS 6.0F╝≥╠σ╫╓┐Γ,╧┬├µ╥╗╠⌡╓╕┴ε╚Ñ╡⌠
  410. ; ╢╘CXDOS,╧┬├µ╥╗╠⌡╓╕┴ε╚Ñ╡⌠
  411.  
  412.     jmp         @t1
  413.  @t20:
  414.     pop         ds
  415.     mov         ax,4301H
  416.     mov         bx,handleOutput
  417.     mov         cx,attrib
  418.     mov         dx,offset fnOutput
  419.     int         21H
  420.     mov         ax,5701H
  421.     mov         bx,handleOutput
  422.     mov         cx,fileTime
  423.     mov         dx,fileDate
  424.     int         21H
  425.     call        near ptr close
  426.     ret
  427.  bind endp
  428.  
  429. ;-------------------------------------------------------;
  430. ; ╓≈│╠╨≥                                                ;
  431. ;-------------------------------------------------------;
  432.  
  433.  start:
  434.     mov         ax,ds
  435.     mov         ss,ax
  436.     mov         sp,100H                 ; ╔Φ╓├╢╤╒╗
  437.     mov         cs:segPsp,ax
  438.     call        near ptr init0          ; │⌡╩╝╗»
  439.     call        near ptr init1
  440.     call        near ptr bind           ; ╫╓─ú╫¬╗╗╙δ└ª░≤
  441.     mov         bx,offset msgWarning    ; ╧╘╩╛╨┼╧ó
  442.     call        near ptr disp
  443.     mov         bx,offset fnOutput      ; ═╦│÷
  444.     call        near ptr error
  445.  
  446. code ends
  447.  
  448. zseg segment
  449. zseg ends
  450.  
  451.      end start
  452.