home *** CD-ROM | disk | FTP | other *** search
/ FreeWare Collection 2 / FreeSoftwareCollection2pd199x-jp.img / ms_dos / ish / ish200s / makehsi.h < prev    next >
Text File  |  1990-06-14  |  36KB  |  1,722 lines

  1. ;
  2. ;        ish file converter for MS-DOS  Ver 2.00 (90/3/27)
  3. ;
  4. ;
  5. ;        Copyright (c) 1986, 1987, 1989, 1990  by  M. ishizuka
  6. ;        All rights reserved.
  7. ;
  8.  
  9.  
  10.  
  11. ;-----------------------------------------------;
  12. ;                        ;
  13. ;    @@mark_idblock_volume_table        ;
  14. ;                        ;
  15. ;    INPUT :    NON                ;
  16. ;    OUTPUT:    ZR (ok)                ;
  17. ;        NZ (already restored)        ;
  18. ;    ERROR :    NON                ;
  19. ;    BREAK :    flags, ax, bx, cl, dx, si    ;
  20. ;                        ;
  21. ;-----------------------------------------------;
  22.  
  23. @@mark_idblock_volume_table    macro
  24.         xor    dx, dx
  25.         mov    ax, word ptr current_division
  26.         dec    ax
  27.         mov    bx, 8d
  28.         div    bx
  29.         mov    si, ax
  30.         add    si, offset idblock_volume_table
  31.         mov    cl, dl
  32.         mov    al, 1
  33.         shl    al, cl
  34.         mov    ah, byte ptr [si]
  35.         xor    byte ptr [si], al
  36.         and    al, ah
  37.         endm
  38.  
  39.  
  40.  
  41. ;-----------------------------------------------;
  42. ;                        ;
  43. ;    @@rename_intermediate_file        ;
  44. ;                        ;
  45. ;    INPUT :    ?
  46. ;    OUTPUT:    ?
  47. ;    ERROR :    ?
  48. ;    BREAK :    ?
  49. ;                        ;
  50. ;-----------------------------------------------;
  51.  
  52. @@rename_intermediate_file    macro
  53.         @@display    msg_rename_1
  54.         push    es
  55.         mov    ax, ds
  56.         mov    es, ax
  57.         mov    si, offset work_fcb_2
  58.         mov    di, offset work_fcb_3
  59.         mov    dx, si
  60. rename_intermediate_file_1:
  61.         lodsb
  62.         stosb
  63.         or    al, al
  64.         jnz    rename_intermediate_file_1
  65.         mov    si, word ptr idblock_header_copy[18]
  66.         mov    al, byte ptr idblock_header_copy[20]
  67.         mov    bx, di
  68.         mov    byte ptr renamed_flag, 0
  69. rename_intermediate_file_2:
  70.         mov    word ptr [bx - 4], si
  71.         mov    byte ptr [bx - 2], al
  72.         mov    di, offset work_fcb_3
  73.         mov    ah, 56h
  74.         int    21h
  75.         mov    di, offset msg_rename
  76.         jnc    rename_intermediate_file_3
  77.         mov    al, '0'
  78.         call    rename_extension
  79.         mov    si, word ptr work_fcb[9]
  80.         mov    al, byte ptr work_fcb[11]
  81.         jnz    rename_intermediate_file_2
  82.         mov    di, offset msg_cannot_rename
  83. rename_intermediate_file_3:
  84.         pop    es
  85.         @@display    di
  86.         mov    si, offset work_fcb_3
  87.         mov    ah, 0
  88. rename_intermediate_file_5:
  89.         call    lodsb_tolower_new
  90.         cmp    al, ' '
  91.         jz    rename_intermediate_file_5
  92.         or    al, al
  93.         jz    rename_intermediate_file_6
  94.         @@dispchr    al
  95.         jmp    rename_intermediate_file_5
  96.  
  97. rename_intermediate_file_6:
  98.         @@dispchr    "'"
  99.         or    al, al        ; clear CY flag
  100. rename_intermediate_file_ret:
  101.         endm
  102.  
  103.  
  104.  
  105. ;-----------------------------------------------;
  106. ;                        ;
  107. ;    @@get_header_frame            ;
  108. ;                        ;
  109. ;    INPUT :    NON                ;
  110. ;    OUTPUT:    flags                ;
  111. ;        ( ZR: OK )            ;
  112. ;    ERROR :    go_next, ?            ;
  113. ;    BREAK :    cx, si, di, ?            ;
  114. ;                        ;
  115. ;-----------------------------------------------;
  116.  
  117. @@get_header_frame    macro
  118. skip_the_same_header_frame:
  119.         call    _get_frame
  120.         jc    go_next
  121.         mov    si, offset work_work
  122.         mov    di, offset work_work2
  123.         mov    cx, 63d
  124.         repz    cmpsb
  125.         jz    skip_the_same_header_frame
  126.         cmp    work_work, 0        ; check sequence number = 0
  127.         endm
  128.  
  129.  
  130.  
  131. ;-----------------------------------------------;
  132. ;                        ;
  133. ;    @@header_save                ;
  134. ;                        ;
  135. ;    INPUT :    NON                ;
  136. ;    OUTPUT:    NON                ;
  137. ;    ERROR :    NON                ;
  138. ;    BREAK :    cx, si, di            ;
  139. ;                        ;
  140. ;-----------------------------------------------;
  141.  
  142. @@header_save    macro
  143.         mov    cx, 63d
  144.         mov    si, offset work_work
  145.         mov    di, offset work_work2
  146.         rep    movsb
  147.         endm
  148.  
  149.  
  150.  
  151. ;-----------------------------------------------;
  152. ;                        ;
  153. ;    @@disp_os                ;
  154. ;                        ;
  155. ;    INPUT :    NON                ;
  156. ;    OUTPUT:    NON                ;
  157. ;    ERROR :    NON                ;
  158. ;    BREAK :    ax, dl                ;
  159. ;                        ;
  160. ;-----------------------------------------------;
  161.  
  162. @@disp_os    macro
  163.         mov    al, '('
  164.         stosb
  165.         mov    al, work_work + 25d
  166.         mov    old_style, al
  167.         mov    al, work_work + 24d
  168.         mov    dl, 'm'
  169.         cmp    al, 10h
  170.         jc    disp_os
  171.         mov    dl, 'c'
  172.         cmp    al, 20h
  173.         jc    disp_os
  174.         mov    dl, '9'
  175.         cmp    al, 30h
  176.         jc    disp_os
  177.         mov    dl, 'u'
  178.         cmp    al, 40h
  179.         jc    disp_os
  180.         mov    dl, 'm'
  181.         cmp    al, 50h
  182.         jnc    disp_os_not_mac
  183.         mov    al, dl
  184.         stosb
  185.         mov    dl, 'a'
  186.         jmp    disp_os
  187.  
  188. disp_os_not_mac:
  189.         mov    dl, '?'
  190.         cmp    al, 0ffh
  191.         jc    disp_os
  192.         mov    dl, '*'
  193. disp_os:    mov    al, dl
  194.         stosb
  195.         mov    ax, ' )'
  196.         stosw
  197.         endm
  198.  
  199.  
  200.  
  201. ;-----------------------------------------------;
  202. ;                        ;
  203. ;    @@disp_division                ;
  204. ;                        ;
  205. ;    INPUT :    NON                ;
  206. ;    OUTPUT:    NON                ;
  207. ;    ERROR :    NON                ;
  208. ;    BREAK :    flags, ax, cx, dx, di        ;
  209. ;                        ;
  210. ;-----------------------------------------------;
  211.  
  212. @@disp_division    macro
  213.         cmp    word ptr current_division, 0
  214.         jz    disp_division_skip
  215.         mov    di, word ptr save_fname2_ptr
  216.         dec    di
  217.         mov    al, '<'
  218.         stosb
  219.         mov    ax, word ptr current_division
  220.         xor    dx, dx
  221.         call    hex_to_dec
  222.         mov    al, '/'
  223.         stosb
  224.         mov    ax, word ptr max_division
  225.         xor    dx, dx
  226.         call    hex_to_dec
  227.         mov    ax,' >'
  228.         stosw
  229.         mov    word ptr save_fname2_ptr, di
  230.         mov    ax, ' :'
  231.         stosw
  232.         mov    cx, di
  233.         sub    cx, offset display_buffer
  234.         @@dispstr2    display_buffer, cx
  235. disp_division_skip:
  236.         endm
  237.  
  238.  
  239.  
  240. ;-----------------------------------------------;
  241. ;                        ;
  242. ;    @@disp_restore_fname            ;
  243. ;                        ;
  244. ;    INPUT :    NON                ;
  245. ;    OUTPUT:    NON                ;
  246. ;    ERROR :    NON                ;
  247. ;    BREAK :    flags, ax, cx, dx, si, di    ;
  248. ;                        ;
  249. ;-----------------------------------------------;
  250.  
  251. @@disp_restore_fname    macro
  252.         mov    si, offset work_work[2]
  253.         mov    di, offset idblock_header_copy
  254.         mov    cx, 42d
  255.         rep    movsb
  256.         mov    si, offset work_work[26d]
  257.         mov    di, offset date_time_flag
  258.         mov    cx, 20d / 2
  259.         rep    movsw
  260.         mov    si, offset work_work + 12d
  261.         call    check_filename
  262.         mov    di, offset work_fcb
  263.         mov    cx, 4
  264.         rep    movsw
  265.         mov    al, '.'
  266.         stosb
  267.         mov    cx, 3
  268.         rep    movsb
  269.         mov    si, offset work_fcb
  270.         mov    di, offset display_buffer
  271.         mov    al, 0dh
  272.         stosb
  273.         mov    byte ptr renamed_flag, 0
  274.         mov    al, '['
  275.         stosb
  276.         mov    ax, line_number_low
  277.         mov    dx, line_number_high
  278.         call    disp_number2
  279.         mov    ax, ' ]'
  280.         stosw
  281.         call    copy_fname_fcb_to_buffer
  282.         @@disp_os
  283.         mov    word ptr save_fname2_ptr, di
  284.         mov    ax, ' :'
  285.         stosw
  286.         mov    cx, di
  287.         sub    cx, offset display_buffer
  288.         @@dispstr2    display_buffer, cx
  289.         endm
  290.  
  291.  
  292.  
  293. ;-----------------------------------------------;
  294. ;                        ;
  295. ;    @@disp_input_fname2            ;
  296. ;                        ;
  297. ;    INPUT :    NON                ;
  298. ;    OUTPUT:    NON                ;
  299. ;    ERROR :    NON                ;
  300. ;    BREAK : flags, ax, dx, si        ;
  301. ;                        ;
  302. ;-----------------------------------------------;
  303.  
  304. @@disp_input_fname2    macro
  305.         cmp    byte ptr stdin, 0
  306.         jnz    disp_input_fname2_2
  307.         mov    si, offset save_input_filename
  308.         mov    ah, 0
  309. disp_input_fname2_1:
  310.         call    lodsb_tolower_new
  311.         or    al, al
  312.         jz    disp_input_fname2_ret
  313.         push    ax
  314.         @@dispchr_stdout    al
  315.         pop    ax
  316.         jmp    disp_input_fname2_1
  317.  
  318. disp_input_fname2_2:
  319.         @@display_stdout    msg_stdin2
  320. disp_input_fname2_ret:
  321.         endm
  322.  
  323.  
  324.  
  325. ;-----------------------------------------------;
  326. ;                        ;
  327. ;    @@disp_restore_fname2            ;
  328. ;                        ;
  329. ;    INPUT :    NON                ;
  330. ;    OUTPUT:    NON                ;
  331. ;    ERROR :    NON                ;
  332. ;    BREAK :    al, cx, dx, si, di        ;
  333. ;                        ;
  334. ;-----------------------------------------------;
  335.  
  336. @@disp_restore_fname2    macro
  337.         @@display_stdout    msg_resfname2_1
  338.         mov    dx, offset work_work3
  339.         mov    si, offset work_fcb
  340.         mov    di, dx
  341.         call    copy_fname_fcb_to_buffer
  342.         mov    al, '$'
  343.         stosb
  344.         @@display_stdout    dx
  345.         @@display_stdout    msg_resfname2_2
  346.         mov    al, work_work + 24d
  347.         mov    dl, 'm'
  348.         cmp    al, 10h
  349.         jc    disp_os_2
  350.         mov    dl, 'c'
  351.         cmp    al, 20h
  352.         jc    disp_os_2
  353.         mov    dl, '9'
  354.         cmp    al, 30h
  355.         jc    disp_os_2
  356.         mov    dl, 'u'
  357.         cmp    al, 40h
  358.         jc    disp_os_2
  359.         mov    dl, 'm'
  360.         cmp    al, 50h
  361.         jnc    disp_os_not_mac_2
  362.         mov    al, dl
  363.         @@dispchr_stdout    dl
  364.         mov    dl, 'a'
  365.         jmp    disp_os_2
  366.  
  367. disp_os_not_mac_2:
  368.         mov    dl, '?'
  369.         cmp    al, 0ffh
  370.         jc    disp_os_2
  371.         mov    dl, '*'
  372. disp_os_2:    @@dispchr_stdout    dl
  373.         mov    dx, offset msg_resfname2_3
  374.         cmp    word ptr current_division, 0
  375.         jz    disp_restore_fname2_1
  376.         @@display_stdout    msg_resfname2_5
  377.         mov    di, offset work_work3
  378.         mov    al, ' '
  379.         stosb
  380.         mov    ax, word ptr current_division
  381.         xor    dx, dx
  382.         call    hex_to_dec
  383.         mov    al, '/'
  384.         stosb
  385.         mov    ax, word ptr max_division
  386.         xor    dx, dx
  387.         call    hex_to_dec
  388.         mov    al, '$'
  389.         stosb
  390.         @@display_stdout    work_work3
  391.         mov    dx, offset msg_resfname2_6
  392. disp_restore_fname2_1:
  393.         @@display_stdout    dx
  394.         @@disp_input_fname2
  395.         @@display_stdout    msg_resfname2_4
  396.         endm
  397.  
  398.  
  399.  
  400. ;-----------------------------------------------;
  401. ;                        ;
  402. ;    @@check_header                ;
  403. ;                        ;
  404. ;    INPUT :    NON                ;
  405. ;    OUTPUT:    NON                ;
  406. ;    ERROR :    error_12            ;
  407. ;    BREAK :    ax, cx, si, di            ;
  408. ;                        ;
  409. ;-----------------------------------------------;
  410.  
  411. @@check_header    macro
  412.         mov    si, offset work_work
  413.         lodsw
  414.         xchg    ah, al
  415.         cmp    ax, MAX_DIVISION_NUMBER
  416.         ja    error_12
  417.         mov    word ptr current_division, ax
  418.         mov    word ptr max_division, ax
  419.         mov    ax, [si+8]
  420.         push    si
  421.         mov    si, offset parameter_jis8
  422.         mov    cl, '8'
  423.         cmp    ax, 808h
  424.         jz    check_header_1
  425.         mov    si, offset parameter_sjis
  426.         mov    cl, 's'
  427.         cmp    ax, 0f10h
  428.         jz    check_header_1
  429.         mov    si, offset parameter_jis7
  430.         mov    cl, '7'
  431.         cmp    ax, 0d10h
  432.         jz    check_header_1
  433.         mov    si, offset parameter_nonkana
  434.         mov    cl, 'n'
  435.         cmp    ax, 0e10h
  436.         jnz    error_12
  437. check_header_1:    mov    type_flag, cl
  438.         mov    di, offset para_81_80
  439.         mov    cx, 21d
  440.         rep    movsw
  441.         mov    ax, word ptr work_work[34]
  442.         cmp    word ptr current_division, 0
  443.         jz    check_header_2
  444.         mov    ax, word ptr work_work[44]
  445. check_header_2:    mov    word ptr crc_check, ax
  446.         pop    si
  447.         lodsw
  448.         mov    length_low_org, ax
  449.         sub    ax, 1
  450.         mov    length_low, ax
  451.         lodsw
  452.         mov    length_high_org, ax
  453.         sbb    ax, 0
  454.         mov    length_high, ax
  455.         lodsw
  456.         cmp    ax, para_69_63
  457.         jnz    error_12
  458.         lodsw
  459.         cmp    ax, para_68_62
  460.         jnz    error_12
  461.         cmp    word ptr current_division, 0
  462.         jz    check_header_6
  463.         mov    si, offset idblock_volume_table
  464.         mov    cx, (offset idblock_volume_table_end - \
  465.                  offset idblock_volume_table) / 2
  466.         xor    ax, ax
  467.         rep    stosw
  468. ;        xor    cx, cx
  469.         mov    ax, word ptr length_low_org
  470.         mov    dx, word ptr length_high_org
  471.         add    ax, 1
  472.         adc    dx, 0
  473. check_header_3:    inc    cx
  474.         sub    ax, word ptr current_division_length_low
  475.         sbb    dx, word ptr current_division_length_high
  476.         jnc    check_header_3
  477.         add    ax, word ptr current_division_length_low
  478.         adc    dx, current_division_length_high
  479.         mov    word ptr max_division, cx
  480.         cmp    cx, current_division
  481.         jnz    check_header_4
  482.         sub    ax, 1
  483.         sbb    dx, 0
  484.         mov    word ptr current_division_length_low, ax
  485.         mov    word ptr current_division_length_high, dx
  486. check_header_4:
  487.         dec    cx
  488.         jz    error_12
  489.         cmp    cx, MAX_DIVISION_NUMBER
  490.         jnc    error_12
  491.         mov    ax, word ptr current_division_length_low
  492.         mov    dx, word ptr current_division_length_high
  493.         sub    ax, 1
  494.         sbb    dx, 0
  495.         mov    word ptr length_low, ax
  496.         mov    word ptr length_high, dx
  497.         mov    ax, word ptr idblock_header_copy[40 - 2]
  498.         mov    dx, word ptr idblock_header_copy[42 - 2]
  499.         mov    word ptr division_offset_low, 0
  500.         mov    word ptr division_offset_high, 0
  501.         mov    cx, word ptr current_division
  502.         dec    cx
  503.         jz    check_header_6
  504. check_header_5:    add    word ptr division_offset_low, ax
  505.         adc    word ptr division_offset_high, dx
  506.         loop    check_header_5
  507. check_header_6:
  508.         endm
  509.  
  510.  
  511.  
  512. ;-----------------------------------------------;
  513. ;                        ;
  514. ;    @@rename_extension_to_000        ;
  515. ;                        ;
  516. ;    INPUT :    al ('0': rename to 000..999)    ;
  517. ;           ('#': rename to #00..#99)    ;
  518. ;    OUTPUT:    NON                ;
  519. ;    ERROR :    NON                ;
  520. ;    BREAK :    NON                ;
  521. ;                        ;
  522. ;-----------------------------------------------;
  523.  
  524. @@rename_extension_to_000    macro
  525.         mov    renamed_flag, al
  526.         mov    byte ptr work_fcb[9], al
  527.         mov    word ptr work_fcb[10], '00'
  528.         endm
  529.  
  530.  
  531.  
  532. ;-----------------------------------------------;
  533. ;                        ;
  534. ;    @@increment_extension            ;
  535. ;                        ;
  536. ;    INPUT :    al ('0': rename to 000..999)    ;
  537. ;           ('#': rename to #00..#99)    ;
  538. ;    OUTPUT:    NON                ;
  539. ;    ERROR :    ZR                ;
  540. ;    BREAK :    flags, al, cx, si, di        ;
  541. ;                        ;
  542. ;-----------------------------------------------;
  543.  
  544. @@increment_extension    macro
  545.         mov    si, offset work_fcb + 11
  546.         mov    di, si
  547.         std
  548.         mov    cx, 3
  549.         cmp    al, '0'
  550.         jz    increment_extension_1
  551.         dec    cl
  552. increment_extension_1:
  553.         lodsb
  554.         inc    al
  555.         cmp    al, '9'+1
  556.         jnz    increment_extension_2
  557.         mov    al, '0'
  558. increment_extension_2:
  559.         stosb
  560.         loopz    increment_extension_1
  561.         cld
  562.         endm
  563.  
  564.  
  565.  
  566. ;-----------------------------------------------;
  567. ;                        ;
  568. ;    @@check_skip_and_create_restore_file    ;
  569. ;                        ;
  570. ;    INPUT :    NON                ;
  571. ;    OUTPUT:    di                ;
  572. ;    ERROR :    error_08, error_11, error_17,    ;
  573. ;        skip_this_file,            ;
  574. ;        disp_restore_fname        ;
  575. ;    BREAK :    flags, ax, bx, cx, dx, si    ;
  576. ;                        ;
  577. ;-----------------------------------------------;
  578.  
  579. @@check_skip_and_create_restore_file    macro
  580.         mov    al, work_work + 24d
  581.         mov    bx, offset msdos_path
  582.         cmp    al, 10h
  583.         jc    check_skip
  584.         mov    bx, offset cpm_path
  585.         cmp    al, 20h
  586.         jc    check_skip
  587.         mov    bx, offset os9_path
  588.         cmp    al, 30h
  589.         jc    check_skip
  590.         mov    bx, offset unix_path
  591.         cmp    al, 40h
  592.         jc    check_skip
  593.         mov    bx, offset mac_path
  594.         cmp    al, 50h
  595.         jc    check_skip
  596.         mov    bx, offset other_os_path
  597.         cmp    al, 0ffh
  598.         jc    check_skip
  599.         mov    bx, offset all_os_path
  600. check_skip:    cmp    byte ptr [bx], 0
  601. ;        jz    skip_other_os_file
  602.         jnz    not_skip
  603. skip_other_os_file:
  604.         @@display    msg_other_os
  605.         jmp    skip_this_file
  606.  
  607. not_skip:    cmp    mode, 'q'
  608.         jnz    check_os_3
  609.         mov    di, offset display_length[2]
  610.         cmp    word ptr current_division, 0
  611.         jz    check_skip_and_create_0
  612.         mov    ax, word ptr current_division_length_low
  613.         mov    dx, word ptr current_division_length_high
  614.         call    hex_to_dec
  615.         mov    al, '/'
  616.         stosb
  617. check_skip_and_create_0:
  618.         mov    ax, word ptr work_work[2]
  619.         mov    dx, word ptr work_work[4]
  620.         call    hex_to_dec
  621.         mov    byte ptr [di], '$'
  622.         @@display    display_length
  623.         @@display    msg_bytes
  624.         mov    dx, offset msg_ext
  625.         cmp    byte ptr shell_escape, 0
  626.         jz    read_answer_0
  627.         mov    dx, offset msg_ext_2
  628. read_answer_0:    @@display    dx
  629. read_answer:    @@int21_8
  630.         call    tolower
  631.         cmp    byte ptr shell_escape, 0
  632.         jz    read_answer_1
  633.         cmp    al, '!'
  634.         jnz    read_answer_1
  635.         call    restore_break
  636.         mov    dx, offset shell
  637.         mov    bx, offset para_block
  638.         mov    ax, ds
  639.         mov    word ptr para_block[4h], ax
  640.         mov    word ptr para_block[8h], ax
  641.         mov    word ptr para_block[0ch], ax
  642.         mov    ax, 4b00h
  643.         int    21h
  644.         jnc    read_answer_0_1
  645.         @@display    msg_cannot_exec_shell
  646. read_answer_0_1:
  647.         mov    byte ptr _dta_id, 0
  648.         call    set_break_on
  649.         jmp    disp_restore_fname
  650.  
  651. read_answer_1:    cmp    al, 'n'
  652. ;        jz    answer_yn
  653.         jz    skip_this_file
  654.         cmp    al, 'q'
  655.         jz    error_17
  656.         cmp    al, 'y'
  657.         jz    answer_yn
  658.         cmp    al, 'r'
  659.         jz    change_mode
  660.         cmp    al, 'a'
  661.         jnz    read_answer
  662.         mov    al, 'r'        ; make 'a' to 'r'
  663. change_mode:    mov    mode, al
  664. answer_yn:
  665. ;        push    ax
  666. ;        @@display    msg_ext_era
  667. ;        pop    ax
  668. ;        cmp    al, 'n'
  669. ;        jz    skip_this_file
  670.         mov    cx, word ptr save_fname2_ptr
  671.         sub    cx, offset display_buffer - 2
  672.         @@dispstr2    display_buffer, cx
  673. check_os_3:    mov    al, work_work + 24d
  674.         mov    byte ptr os, al
  675.         mov    ax, word ptr work_work[2]
  676.         mov    word ptr fsize_low, ax
  677.         mov    ax, word ptr work_work[4]
  678.         mov    word ptr fsize_high, ax
  679.         cmp    byte ptr stdout, 0
  680.         jnz    check_skip_and_create_1
  681.         call    cmpfile_or_outputfile_open
  682.         jmp    check_skip_and_create_skip
  683.  
  684. check_skip_and_create_1:
  685.         cmp    current_division, 0
  686.         jz    check_skip_and_create_2
  687.         mov    ax, word ptr current_division_length_low
  688.         mov    word ptr fsize_low, ax
  689.         mov    word ptr length_low_org, ax
  690.         mov    ax, word ptr current_division_length_high
  691.         mov    word ptr fsize_high, ax
  692.         mov    word ptr length_high_org, ax
  693. check_skip_and_create_2:
  694.         @@disp_restore_fname2
  695.         mov    di, word ptr save_fname2_ptr
  696. check_skip_and_create_skip:
  697.         endm
  698.  
  699.  
  700.  
  701. ;-----------------------------------------------;
  702. ;                        ;
  703. ;    @@disp_periods                ;
  704. ;                        ;
  705. ;    INPUT :    di                ;
  706. ;    OUTPUT:    NON                ;
  707. ;    ERROR :    NON                ;
  708. ;    BREAK :    flags, ax, cx, dx, si, di    ;
  709. ;                        ;
  710. ;-----------------------------------------------;
  711.  
  712. @@disp_periods    macro
  713.         mov    si, offset msg_br5
  714.         movsb
  715.         movsw
  716.         mov    word ptr line_number_ptr, di
  717.         movsw
  718.         mov    ax, word ptr para_65_59
  719.         mov    word ptr para_A, ax
  720.         mov    ax, word ptr para_66_60
  721.         mov    word ptr para_B, ax
  722.         mov    ax, word ptr fsize_low
  723.         mov    dx, word ptr fsize_high
  724.         add    ax, 2
  725.         adc    dx, 0
  726.         call    trunc
  727.         push    ax
  728.         push    dx
  729.         call    trunc
  730.         pop    si
  731.         pop    bp
  732.         push    ax
  733.         push    dx
  734.         add    ax, ax
  735.         adc    dx, dx
  736.         add    ax, bp
  737.         adc    dx, si
  738.         call    hex_to_dec
  739.         mov    ax, ' )'
  740.         stosw
  741.         pop    dx
  742.         pop    cx
  743.         or    dx, dx
  744.         jz    disp_periods_1
  745.         mov    cx, 80d
  746. disp_periods_1:    mov    ax, 80d + offset display_buffer
  747.         sub    ax, di
  748.         cmp    cx, ax
  749.         jc    disp_periods_2
  750.         mov    cx, ax
  751. disp_periods_2:    mov    word ptr block_number_ptr, di
  752.         mov    word ptr block_number_begin, di
  753.         mov    al, '.'
  754.         rep    stosb
  755.         mov    cx, 80d + offset display_buffer
  756.         sub    cx, di
  757.         mov    al, ' '
  758.         rep    stosb
  759.         call    draw_display_buffer
  760.         endm
  761.  
  762.  
  763.  
  764. ;-----------------------------------------------;
  765. ;                        ;
  766. ;    @@disp_periods2                ;
  767. ;                        ;
  768. ;    INPUT :    di                ;
  769. ;    OUTPUT:    NON                ;
  770. ;    ERROR :    NON                ;
  771. ;    BREAK :    flags, ax, cx, dx, si, di    ;
  772. ;                        ;
  773. ;-----------------------------------------------;
  774.  
  775. @@disp_periods2    macro
  776.         mov    si, di
  777.         mov    cx, 3
  778. disp_periods2_1:
  779.         lodsb
  780.         cmp    al, '0'
  781.         jc    disp_periods2_2
  782.         cmp    al, '9' + 1
  783.         jc    disp_periods2_3
  784. disp_periods2_2:
  785.         loop    disp_periods2_1
  786.         jmp    disp_periods2_ret
  787.  
  788. disp_periods2_3:
  789.         std
  790. disp_periods2_4:
  791.         push    cx
  792.         mov    si, offset display_buffer[79]
  793.         mov    al, [si]
  794.         cmp    al, ' '
  795.         jz    disp_periods2_5
  796.         cmp    al, '.'
  797.         jnz    disp_periods2_6
  798. disp_periods2_5:
  799.         mov    cx, si
  800.         sub    cx, di
  801.         push    di
  802.         mov    di, si
  803.         dec    si
  804.         rep    movsb
  805.         pop    di
  806.         pop    cx
  807.         inc    word ptr block_number_begin
  808.         inc    word ptr block_number_ptr
  809.         inc    word ptr line_number_ptr
  810.         loop    disp_periods2_4
  811.         jmp    disp_periods2_8
  812.  
  813. disp_periods2_6:
  814.         cld
  815.         mov    si, word ptr line_number_ptr
  816. disp_periods2_7:
  817.         lodsb
  818.         cmp    al, ' '
  819.         jnz    disp_periods2_7
  820.         mov    cx, si
  821.         dec    si
  822.         sub    cx, di
  823.         pop    bp
  824.         push    di
  825.         mov    di, si
  826.         add    di, bp
  827.         std
  828.         rep    movsb
  829.         pop    di
  830.         add    word ptr block_number_begin, bp
  831.         add    word ptr line_number_ptr, bp
  832. disp_periods2_8:
  833.         cld
  834.         mov    si, offset msg_br5
  835.         movsb
  836.         movsw
  837. disp_periods2_ret:
  838.         call    draw_display_buffer
  839.         endm
  840.  
  841.  
  842.  
  843. ;-----------------------------------------------;
  844. ;                        ;
  845. ;    @@increment_line_number            ;
  846. ;                        ;
  847. ;    INPUT :    NON                ;
  848. ;    OUTPUT:    NON                ;
  849. ;    ERROR :    NON                ;
  850. ;    BREAK :    flags, al, cx, si, di        ;
  851. ;                        ;
  852. ;-----------------------------------------------;
  853.  
  854. @@increment_line_number    macro
  855.         mov    si, word ptr line_number_ptr
  856. increment_line_number_1:
  857.         mov    al, [si]
  858.         cmp    al, '0'
  859.         jb    increment_line_number_2
  860.         cmp    al, '9' + 1
  861.         jnb    increment_line_number_2
  862.         inc    al
  863.         cmp    al, '9' + 1
  864.         jb    increment_line_number_7
  865.         mov    al, '0'
  866.         mov    [si], al
  867.         dec    si
  868.         jmp    increment_line_number_1
  869.  
  870. increment_line_number_2:
  871.         mov    di, offset display_buffer[79]
  872.         mov    al, [di]
  873.         cmp    al, ' '
  874.         jz    increment_line_number_4
  875.         cmp    al, '.'
  876.         jz    increment_line_number_4
  877.         xor    cx, cx
  878.         mov    al, ' '
  879.         mov    di, si
  880. increment_line_number_3:
  881.         inc    cx
  882.         scasb
  883.         jnz    increment_line_number_3
  884.         jmp    increment_line_number_5
  885.  
  886. increment_line_number_4:
  887.         mov    cx, di
  888.         sub    cx, si
  889. increment_line_number_5:
  890.         mov    si, di
  891.         dec    si
  892.         dec    cx
  893.         std
  894.         rep    movsb
  895.         cld
  896.         mov    byte ptr [di], '1'
  897.         inc    word ptr line_number_ptr
  898.         inc    word ptr block_number_begin
  899.         inc    word ptr block_number_ptr
  900.         call    draw_display_buffer
  901.         jmp    increment_line_number_ret
  902.  
  903. increment_line_number_7:
  904.         mov    [si], al
  905.         cmp    qu_flag, 0
  906.         jnz    increment_line_number_ret
  907.         mov    cx, word ptr line_number_ptr
  908.         sub    cx, si
  909.         inc    cx
  910.         push    cx
  911. disp_line_number_now:
  912.         @@dispchr    08h
  913.         loop    disp_line_number_now
  914.         pop    cx
  915.         @@dispstr2    si, cx
  916. increment_line_number_ret:
  917.         endm
  918.  
  919.  
  920.  
  921. ;-----------------------------------------------;
  922. ;                        ;
  923. ;    @@disp_renamed_fname            ;
  924. ;                        ;
  925. ;    INPUT :    NON                ;
  926. ;    OUTPUT:    NON                ;
  927. ;    ERROR :    error_08, error_11, error_17,    ;
  928. ;        skip_this_file            ;
  929. ;    BREAK :    flags, ax, bx, cx, dx, si, di    ;
  930. ;                        ;
  931. ;-----------------------------------------------;
  932.  
  933. @@disp_renamed_fname    macro
  934.         mov    di, word ptr save_fname2_ptr
  935.         cmp    cmpfile_handler, 0
  936.         mov    ax, ' ?'
  937.         jnz    disp_renamed_fname_skip
  938.         cmp    renamed_flag, 0        ; if extension is not renamed
  939.         jz    disp_renamed_fname_ret    ; then skip
  940.         mov    ax, ' >'
  941. disp_renamed_fname_skip:
  942.         stosw
  943.         mov    si, offset work_fcb
  944.         call    copy_fname_fcb_to_buffer
  945. disp_renamed_fname_ret:
  946.         endm
  947.  
  948.  
  949.  
  950. ;-----------------------------------------------;
  951. ;                        ;
  952. ;    @@make_table2                ;
  953. ;                        ;
  954. ;    INPUT :    NON                ;
  955. ;    OUTPUT:    NON                ;
  956. ;    ERROR :    ?
  957. ;    BREAK :    flags, ax, bx, cx, dx, si
  958. ;                        ;
  959. ;-----------------------------------------------;
  960.  
  961. @@make_table2    macro
  962. make_table2:    mov    ax, line_number_low
  963.         mov    line_save_low, ax
  964.         mov    ax, line_number_high
  965.         mov    line_save_high, ax
  966.         call    _get_frame
  967.         jc    make_table2_3
  968.         mov    si, offset work_work
  969.         lodsb
  970. make_table2_1:    cmp    al, seq_old
  971.         jnz    not_duplicate
  972.         or    al, al
  973.         jnz    make_table2
  974.         push    si
  975.         push    di
  976.         mov    si, offset work_work
  977.         mov    di, offset work_work2
  978.         mov    cx, 63d
  979.         repz    cmpsb
  980.         pop    di
  981.         pop    si
  982.         jz    make_table2
  983. not_duplicate:    cmp    al, byte ptr para_69_63
  984.         jnz    make_table2_2
  985.         mov    cx, para_66_60
  986.         mov    ah, 0 - (offset sum_1_to_61)
  987.         cmp    byte ptr type_flag, '7'
  988.         jz    calc_slant_sum
  989.         mov    ah, 0 - (offset sum_1_to_71)
  990.         cmp    byte ptr type_flag, 's'
  991.         jz    calc_slant_sum
  992.         mov    ah, 0 - (offset sum_1_to_67)
  993. calc_slant_sum:    lodsb
  994.         sub    ah, al
  995.         loop    calc_slant_sum
  996.         mov    [si], ah
  997.         mov    al, byte ptr para_68_62
  998. make_table2_2:    call    seq_new
  999.         cmp    al, seq_old
  1000.         jz    seq_ok
  1001.         mov    ah, error_count
  1002.         mov    bl, ah
  1003.         add    bl, bl
  1004.         add    bl, bl
  1005.         add    bl, ah
  1006.         xor    bh, bh
  1007.         add    bx, offset error_seq
  1008.         inc    ah
  1009.         mov    error_count, ah
  1010.         cmp    ah, 3
  1011.         mov    ah, seq_old
  1012.         mov    byte ptr [bx], ah
  1013.         pushf
  1014.         push    ax
  1015.         mov    ax, line_save_low
  1016.         inc    ax
  1017.         cmp    ax, 10000d
  1018.         jnz    line_number_save_1
  1019.         inc    line_save_high
  1020.         xor    ax, ax
  1021. line_number_save_1:
  1022.         mov    line_save_low, ax
  1023.         mov    word ptr [bx+1], ax
  1024.         mov    ax, line_save_high
  1025.         mov    word ptr [bx+3], ax
  1026.         pop    ax
  1027.         popf
  1028.         jb    make_table2_2
  1029.         jmp    error_14
  1030.  
  1031. make_table2_3:    mov    al, 0ffh
  1032.         jmp    make_table2_2
  1033.  
  1034. seq_ok:        mov    cx, para_69_63
  1035.         mov    si, offset work_work
  1036.         mov    di, offset work_table
  1037.         cmp    al, byte ptr para_68_62
  1038.         jnz    not_slant_line
  1039.         inc    si
  1040. not_slant_line:    dec    ax
  1041.         mul    cl
  1042.         add    di, ax
  1043.         rep    movsb
  1044.         cmp    word ptr end_length, 0
  1045.         jz    make_table2
  1046.         mov    al, byte ptr seq_old
  1047.         cmp    al, byte ptr para_68_62
  1048.         jz    make_table2_2
  1049.         jmp    make_table2
  1050.  
  1051. ;make_table2_4:    
  1052. ;        mov    al, 0ffh
  1053. ;        call    seq_new
  1054. ;        jmp    make_table2
  1055.         endm
  1056.  
  1057.  
  1058.  
  1059. ;-----------------------------------------------;
  1060. ;                        ;
  1061. ;    @@two_line_errors            ;
  1062. ;                        ;
  1063. ;    INPUT :    al (error line's sequence number)
  1064. ;    OUTPUT:    NON                ;
  1065. ;    ERROR :    NON                ;
  1066. ;    BREAK :    flags, ax, bx, cx, dx, si    ;
  1067. ;                        ;
  1068. ;-----------------------------------------------;
  1069.  
  1070. @@two_line_errors    macro
  1071.         mov    si, offset work_table
  1072.         mov    dl, al
  1073.         dec    al
  1074.         mov    dh, byte ptr para_69_63
  1075.         mul    dh
  1076.         add    ax, si
  1077.         mov    word ptr line2, ax
  1078.         mov    al, error_seq
  1079.         push    ax
  1080.         sub    dl, al
  1081.         dec    al
  1082.         mul    dh
  1083.         add    si, ax
  1084.         mov    word ptr line1, si
  1085.         pop    ax
  1086.         mov    [si], al
  1087.         xor    dh, dh
  1088.         mov    cx, para_67_61
  1089.         xor    bx, bx
  1090. two_line_errors_1:
  1091.         push    cx
  1092.         push    si
  1093.         xor    al, al
  1094.         mov    cx, para_68_62
  1095. two_line_errors_2:
  1096.         add    al, [si+bx]
  1097.         add    si, para_69_63
  1098.         cmp    si, para_69$68_63$62_work_table
  1099.         jb    two_line_errors_3
  1100.         sub    si, para_69$68_63$62
  1101.         dec    bx
  1102. two_line_errors_3:
  1103.         inc    bx
  1104.         cmp    bx, para_67_61
  1105.         jb    two_line_errors_4
  1106.         xor    bx, bx
  1107. two_line_errors_4:
  1108.         loop    two_line_errors_2
  1109.         add    bx, dx
  1110.         cmp    bx, para_67_61
  1111.         jb    two_line_errors_5
  1112.         sub    bx, para_67_61
  1113. two_line_errors_5:
  1114.         sub    [bx][8000h], al
  1115. line2        equ    $-2
  1116.         xor    al, al
  1117.         mov    cx, para_67_61
  1118.         mov    si, offset work_table
  1119. two_line_errors_6:    add    al, [si+bx]
  1120.         add    si, para_69_63
  1121.         loop    two_line_errors_6
  1122.         sub    [bx][8000h], al
  1123. line1    equ    $-2
  1124.         pop    si
  1125.         pop    cx
  1126.         loop    two_line_errors_1
  1127.         endm
  1128.  
  1129.  
  1130.  
  1131. ;-----------------------------------------------;
  1132. ;                        ;
  1133. ;    @@one_line_error            ;
  1134. ;                        ;
  1135. ;    INPUT :    NON                ;
  1136. ;    OUTPUT:    NON                ;
  1137. ;    ERROR :    NON                ;
  1138. ;    BREAK :    flags, ax, bx, cx, si        ;
  1139. ;                        ;
  1140. ;-----------------------------------------------;
  1141.  
  1142. @@one_line_error    macro
  1143.         mov    si, offset work_table +1
  1144.         mov    al, error_seq
  1145.         dec    al
  1146.         mov    ah, byte ptr para_69_63
  1147.         mul    ah
  1148.         mov    word ptr line3, ax
  1149.         mov    cx, para_66_60
  1150. one_line_error_1:
  1151.         push    cx
  1152.         xor    bx, bx
  1153.         mov    cx, para_67_61
  1154.         xor    al, al
  1155. one_line_error_2:
  1156.         add    al, [si+bx]
  1157.         add    bx, para_69_63
  1158.         loop    one_line_error_2
  1159.         sub    [si][8000h], al
  1160. line3        equ    $-2
  1161.         inc    si
  1162.         pop    cx
  1163.         loop    one_line_error_1
  1164.         endm
  1165.  
  1166.  
  1167.  
  1168. ;-----------------------------------------------;
  1169. ;                        ;
  1170. ;    @@correct_errors            ;
  1171. ;                        ;
  1172. ;    INPUT :    NON                ;
  1173. ;    OUTPUT:    NON                ;
  1174. ;    ERROR :    NON                ;
  1175. ;    BREAK :    flags, ax, bx, cx, dx, si    ;
  1176. ;                        ;
  1177. ;-----------------------------------------------;
  1178.  
  1179. @@correct_errors    macro
  1180.         mov    al, error_count
  1181.         or    al, al
  1182.         jz    correct_complete
  1183.         dec    al
  1184.         jz    one_line_error
  1185.         mov    al, error_seq[5]
  1186.         cmp    al, byte ptr para_68_62
  1187.         jz    one_line_error
  1188.         @@two_line_errors
  1189.         jmp    correct_complete
  1190.  
  1191. one_line_error:    @@one_line_error
  1192.  
  1193. correct_complete:
  1194.         endm
  1195.  
  1196.  
  1197.  
  1198. ;-----------------------------------------------;
  1199. ;                        ;
  1200. ;    @@com_cmpfile_cx            ;
  1201. ;                        ;
  1202. ;    INPUT :    cx (compare byte count)        ;
  1203. ;    OUTPUT:    flags                ;
  1204. ;        ( ZR : compare OK )        ;
  1205. ;    ERROR :    NON                ;
  1206. ;    BREAK :    si, di, flags            ;
  1207. ;                        ;
  1208. ;-----------------------------------------------;
  1209.  
  1210. @@cmp_cmpfile_cx    macro
  1211.         push    cx
  1212.         mov    si, offset write_buffer
  1213.         mov    di, offset cmp_buffer
  1214.         repz    cmpsb
  1215.         pop    cx
  1216.         endm
  1217.  
  1218.  
  1219.  
  1220. ;-----------------------------------------------;
  1221. ;                        ;
  1222. ;    @@cmp_old_and_new_sub            ;
  1223. ;                        ;
  1224. ;    INPUT :    cx (compare byte count)        ;
  1225. ;    OUTPUT:    flags                ;
  1226. ;        ( ZR : compare OK )        ;
  1227. ;    ERROR :    NON                ;
  1228. ;    BREAK :    cx, si, di, flags        ;
  1229. ;                        ;
  1230. ;-----------------------------------------------;
  1231.  
  1232. @@cmp_old_and_new_sub    macro
  1233.         mov    si, offset work_table
  1234.         mov    di, offset cmp_buffer
  1235.         repz    cmpsb
  1236.         endm
  1237.  
  1238.  
  1239.  
  1240. ;-----------------------------------------------;
  1241. ;                        ;
  1242. ;    @@cmp_oldcmpfile_and_newcmpfile        ;
  1243. ;                        ;
  1244. ;    INPUT :    ?                ;
  1245. ;    OUTPUT:    ?                ;
  1246. ;    ERROR :    ?                ;
  1247. ;    BREAK :    ?                ;
  1248. ;                        ;
  1249. ;-----------------------------------------------;
  1250.  
  1251. @@cmp_oldcmpfile_and_newcmpfile    macro
  1252.         push    cx
  1253.         mov    ax, word ptr cmp_done_low
  1254.         mov    dx, word ptr cmp_done_high
  1255. cmp_old_and_new_1:
  1256.         mov    cx, 1000h
  1257.         sub    ax, cx
  1258.         sbb    dx, 0
  1259.         jnc    cmp_old_and_new_2
  1260.         add    cx, ax
  1261.         jz    cmp_old_and_new_ret
  1262.         xor    ax, ax
  1263.         xor    dx, dx
  1264. cmp_old_and_new_2:
  1265.         push    ax
  1266.         push    dx
  1267.         push    cx
  1268.         @@read_cmpfile_cx
  1269.         pop    cx
  1270.         push    cx
  1271.         @@read_oldcmpfile_cx
  1272.         pop    cx
  1273.         @@cmp_old_and_new_sub
  1274.         pop    dx
  1275.         pop    ax
  1276.         jz    cmp_old_and_new_1
  1277. cmp_old_and_new_ret:
  1278.         pop    cx
  1279.         endm
  1280.  
  1281.  
  1282.  
  1283. ;-----------------------------------------------;
  1284. ;                        ;
  1285. ;    @@copy_cmpfile_to_outputfile        ;
  1286. ;                        ;
  1287. ;    INPUT :    ?                ;
  1288. ;    OUTPUT:    ?                ;
  1289. ;    ERROR :    ?                ;
  1290. ;    BREAK :    ?                ;
  1291. ;                        ;
  1292. ;-----------------------------------------------;
  1293.  
  1294. @@copy_cmpfile_to_outputfile    macro
  1295.         mov    ax, word ptr cmp_done_low
  1296.         mov    dx, word ptr cmp_done_high
  1297. copy_cmpfile_to_outputfile_1:
  1298.         mov    cx, 1000h
  1299.         sub    ax, cx
  1300.         sbb    dx, 0
  1301.         jnc    copy_cmpfile_to_outputfile_2
  1302.         add    cx, ax
  1303.         jz    copy_cmpfile_to_outputfile_ret
  1304.         xor    ax, ax
  1305.         xor    dx, dx
  1306. copy_cmpfile_to_outputfile_2:
  1307.         push    ax
  1308.         push    dx
  1309.         push    cx
  1310.         @@read_oldcmpfile_cx
  1311.         pop    cx
  1312.         mov    dx, offset work_table
  1313.         call    write_2
  1314.         pop    dx
  1315.         pop    ax
  1316.         jz    copy_cmpfile_to_outputfile_1
  1317. copy_cmpfile_to_outputfile_ret:
  1318.         endm
  1319.  
  1320.  
  1321.  
  1322. ;-----------------------------------------------;
  1323. ;                        ;
  1324. ;    @@close_cmpfile                ;
  1325. ;                        ;
  1326. ;    INPUT :    bx (handler)            ;
  1327. ;    OUTPUT:    NON                ;
  1328. ;    ERROR :    error_24            ;
  1329. ;    BREAK :    ax, flags            ;
  1330. ;                        ;
  1331. ;-----------------------------------------------;
  1332.  
  1333. @@close_cmpfile    macro
  1334.         mov    ah, 3eh
  1335.         int    21h
  1336.         jc    error_24
  1337.         endm
  1338.  
  1339.  
  1340.  
  1341. ;-----------------------------------------------;
  1342. ;                        ;
  1343. ;    @@close_newcmpfile            ;
  1344. ;                        ;
  1345. ;    INPUT :    NON                ;
  1346. ;    OUTPUT:    NON                ;
  1347. ;    ERROR :    error_24            ;
  1348. ;    BREAK :    ax, bx, flags            ;
  1349. ;                        ;
  1350. ;-----------------------------------------------;
  1351.  
  1352. @@close_newcmpfile    macro
  1353.         mov    bx, word ptr cmpfile_handler
  1354.         @@close_cmpfile
  1355.         endm
  1356.  
  1357.  
  1358.  
  1359. ;-----------------------------------------------;
  1360. ;                        ;
  1361. ;    @@close_oldcmpfile            ;
  1362. ;                        ;
  1363. ;    INPUT :    NON                ;
  1364. ;    OUTPUT:    NON                ;
  1365. ;    ERROR :    error_24            ;
  1366. ;    BREAK :    ax, bx, flags            ;
  1367. ;                        ;
  1368. ;-----------------------------------------------;
  1369.  
  1370. @@close_oldcmpfile    macro
  1371.         mov    bx, word ptr cmpfile_handler2
  1372.         @@close_cmpfile
  1373.         endm
  1374.  
  1375.  
  1376.  
  1377. ;-----------------------------------------------;
  1378. ;                        ;
  1379. ;    @@read_cmpfile_cx            ;
  1380. ;                        ;
  1381. ;    INPUT :    cx (compare byte count)        ;
  1382. ;    OUTPUT:    NON                ;
  1383. ;    ERROR :    error_24            ;
  1384. ;    BREAK :    ax, bx, dx, flags        ;
  1385. ;                        ;
  1386. ;-----------------------------------------------;
  1387.  
  1388. @@read_cmpfile_cx    macro
  1389.         mov    ah, 3fh
  1390.         mov    bx, word ptr cmpfile_handler
  1391.         mov    dx, offset cmp_buffer
  1392.         int    21h
  1393.         jc    error_24
  1394.         cmp    ax, cx
  1395.         jnz    error_24
  1396.         endm
  1397.  
  1398.  
  1399.  
  1400. ;-----------------------------------------------;
  1401. ;                        ;
  1402. ;    @@read_oldcmpfile_cx            ;
  1403. ;                        ;
  1404. ;    INPUT :    cx (compare byte count)        ;
  1405. ;    OUTPUT:    NON                ;
  1406. ;    ERROR :    error_24            ;
  1407. ;    BREAK :    ax, bx, dx, flags        ;
  1408. ;                        ;
  1409. ;-----------------------------------------------;
  1410.  
  1411. @@read_oldcmpfile_cx    macro
  1412.         mov    ah, 3fh
  1413.         mov    bx, word ptr cmpfile_handler2
  1414.         mov    dx, offset work_table
  1415.         int    21h
  1416.         jc    error_24
  1417.         cmp    ax, cx
  1418.         jnz    error_24
  1419.         endm
  1420.  
  1421.  
  1422.  
  1423. ;-----------------------------------------------;
  1424. ;                        ;
  1425. ;    @@rewind_oldcmpfile            ;
  1426. ;                        ;
  1427. ;    INPUT :    cx (compare byte count)        ;
  1428. ;    OUTPUT:    NON                ;
  1429. ;    ERROR :    error_24            ;
  1430. ;    BREAK :    ax, bx, dx, flags        ;
  1431. ;                        ;
  1432. ;-----------------------------------------------;
  1433.  
  1434. @@rewind_oldcmpfile    macro
  1435.         mov    ax, 4200h
  1436.         mov    bx, word ptr cmpfile_handler2
  1437.         xor    cx, cx
  1438.         xor    dx, dx
  1439.         int    21h
  1440.         jc    error_24
  1441.         endm
  1442.  
  1443.  
  1444.  
  1445. ;-----------------------------------------------;
  1446. ;                        ;
  1447. ;    @@compare_file_cx            ;
  1448. ;                        ;
  1449. ;    INPUT :    cx (compare byte count)        ;
  1450. ;    OUTPUT:    flags                ;
  1451. ;        ( ZR : compare OK )        ;
  1452. ;    ERROR :    error_24, ?            ;
  1453. ;    BREAK :    ?                ;
  1454. ;                        ;
  1455. ;-----------------------------------------------;
  1456.  
  1457. @@compare_file_cx    macro
  1458. compare_file_cx_1:
  1459.         @@read_cmpfile_cx
  1460.         @@cmp_cmpfile_cx
  1461.         jz    compare_file_cx_ret
  1462.         mov    ax, word ptr cmpfile_handler
  1463.         mov    word ptr cmpfile_handler2, ax
  1464. compare_file_cx_2:
  1465.         push    cx
  1466.         @@rewind_oldcmpfile
  1467.         call    cmpfile_or_outputfile_open
  1468.         @@disp_periods2
  1469.         pop    cx
  1470.         cmp    word ptr cmpfile_handler, 0
  1471.         jz    compare_file_not_found
  1472.         @@cmp_oldcmpfile_and_newcmpfile
  1473.         jz    compare_file_cx_3
  1474.         @@close_newcmpfile
  1475.         jmp    compare_file_cx_2
  1476.  
  1477. compare_file_cx_3:
  1478.         @@close_oldcmpfile
  1479.         jmp    compare_file_cx_1
  1480.  
  1481. compare_file_not_found:
  1482.         push    cx
  1483.         @@copy_cmpfile_to_outputfile
  1484.         pop    cx
  1485. compare_file_cx_ret:
  1486.         endm
  1487.  
  1488.  
  1489.  
  1490. ;-----------------------------------------------;
  1491. ;                        ;
  1492. ;    @@write_buffer_from_table        ;
  1493. ;                        ;
  1494. ;    INPUT :    NON                ;
  1495. ;    OUTPUT:    NON                ;
  1496. ;    ERROR :    error_13, ?
  1497. ;    BREAK :    flags, ax, bx, cx, dx, si, di, bp, ?
  1498. ;                        ;
  1499. ;-----------------------------------------------;
  1500.  
  1501. @@write_buffer_from_table    macro
  1502.         mov    cx, para_66_60
  1503.         mov    si, offset work_table + 1
  1504.         mov    di, offset write_buffer
  1505. write_buffer_from_table_1:
  1506.         push    cx
  1507.         mov    cx, para_33_30
  1508.         rep    movsw
  1509.         add    si, 3
  1510.         pop    cx
  1511.         loop    write_buffer_from_table_1
  1512.         mov    bp, word ptr crc
  1513.         mov    ax, word ptr crc_32
  1514.         mov    dx, word ptr crc_32[2]
  1515.         mov    si, offset write_buffer
  1516.         mov    cx, word ptr end_length2
  1517.         or    cx, cx
  1518.         jnz    write_buffer_from_table_2
  1519.         cmp    word ptr end_length, 0
  1520.         jnz    calc_crc_2
  1521.         mov    cx, para_66$66_60$60
  1522. write_buffer_from_table_2:
  1523.         cmp    byte ptr crc_flag, 0    ; calculating crc or not
  1524.         jz    calc_crc_1        ; if already calculating
  1525.                         ;  then skip
  1526.         mov    byte ptr crc_flag, 0
  1527.         mov    ax, 0ffffh
  1528.         mov    dx, ax
  1529.         mov    bp, ax
  1530. calc_crc_1:    @@crc16_32_sub
  1531.         mov    word ptr crc, bp
  1532.         mov    word ptr crc_32, ax
  1533.         mov    word ptr crc_32[2], dx
  1534.         cmp    word ptr end_length, 0
  1535.         jz    calc_crc_4
  1536. calc_crc_2:    cmp    word ptr end_length, 1
  1537.         jnz    calc_crc_2_1
  1538.         dec    si
  1539. calc_crc_2_1:    not    bp
  1540.         cmp    bp, word ptr [si]
  1541.         jnz    error_13
  1542.         mov    cx, 1000h
  1543.         cmp    word ptr max_division, 0
  1544.         jnz    calc_crc_3
  1545.         mov    ch, 4
  1546.         test    byte ptr date_time_flag, 8
  1547.         jz    calc_crc_3
  1548.         cmp    ax, word ptr crc_32
  1549.         jnz    error_28_0
  1550.         cmp    dx, word ptr crc_32[2]
  1551.         jnz    error_28_0
  1552.         mov    cl, 2
  1553. calc_crc_3:    test    byte ptr date_time_flag, ch
  1554.         jz    calc_crc_4
  1555.         cmp    bp, word ptr crc_check
  1556.         jnz    error_27_0
  1557.         mov    cl, 1
  1558. calc_crc_4:    mov    cx, word ptr end_length2
  1559.         or    cx, cx
  1560.         jnz    write_buffer_from_table_3
  1561.         cmp    word ptr end_length, 0
  1562.         jnz    write_buffer_from_table_4
  1563.         mov    cx, para_66$66_60$60
  1564. write_buffer_from_table_3:
  1565.         lodsb
  1566.         mov    byte ptr save_data, al
  1567.         cmp    word ptr cmpfile_handler, 0
  1568.         jz    write_buffer_from_table_3_1
  1569.         @@compare_file_cx
  1570.         add    word ptr cmp_done_low, cx
  1571.         adc    word ptr cmp_done_high, 0
  1572.         cmp    word ptr cmpfile_handler, 0
  1573.         jnz    write_buffer_from_table_4
  1574. write_buffer_from_table_3_1:
  1575.         call    write
  1576. write_buffer_from_table_4:
  1577.         cmp    word ptr end_length, 0
  1578.         jz    write_buffer_from_table_5
  1579.         cmp    word ptr cmpfile_handler, 0
  1580.         pushf
  1581.         mov    byte ptr restore_ok, 0ffh
  1582.         call    _write_close
  1583.         jb    error_09
  1584.         popf
  1585.         mov    dx, offset msg_same_of_hsi
  1586.         jnz    cmp_file_2
  1587.         inc    word ptr restore_count
  1588.         mov    dx, offset msg_ok_of_hsi
  1589.         cmp    word ptr max_division, 0
  1590.         jz    cmp_file_2
  1591.         dec    word ptr restore_count
  1592.         inc    word ptr restore_volume_count
  1593.         mov    dx, offset msg_ok_of_hsi2
  1594. cmp_file_2:    @@display    dx
  1595. write_buffer_from_table_5:
  1596.         mov    byte ptr error_count, 0
  1597.         endm
  1598.  
  1599.  
  1600.  
  1601. ;-----------------------------------------------;
  1602. ;                        ;
  1603. ;    @@write_buffer_from_table2        ;
  1604. ;                        ;
  1605. ;    INPUT :    NON                ;
  1606. ;    OUTPUT:    NON                ;
  1607. ;    ERROR :    ?
  1608. ;    BREAK :    flags, ax, bx, cx, dx, si, di, ?
  1609. ;                        ;
  1610. ;-----------------------------------------------;
  1611.  
  1612. @@write_buffer_from_table2    macro
  1613.         mov    cx, para_66_60
  1614.         mov    si, offset work_table + 1
  1615.         mov    di, offset write_buffer
  1616. write_buffer_from_table2_1:
  1617.         push    cx
  1618.         mov    cx, para_33_30
  1619.         rep    movsw
  1620.         add    si, 3
  1621.         pop    cx
  1622.         loop    write_buffer_from_table2_1
  1623.         mov    si, offset write_buffer
  1624.         mov    dx, offset crc_table
  1625.         mov    cx, word ptr end_length2
  1626.         or    cx, cx
  1627.         jnz    write_buffer_from_table2_3
  1628.         cmp    word ptr end_length, 0
  1629.         jnz    write_buffer_from_table_4
  1630.         mov    cx, para_66$66_60$60
  1631. write_buffer_from_table2_3:
  1632.         call    write
  1633. write_buffer_from_table2_4:
  1634.         endm
  1635.  
  1636.  
  1637.  
  1638. ;-----------------------------------------------;
  1639. ;                        ;
  1640. ;    @@chk_table                ;
  1641. ;                        ;
  1642. ;    INPUT :    NON                ;
  1643. ;    OUTPUT:    NON                ;
  1644. ;    ERROR :    ?                ;
  1645. ;    BREAK :    flags, ?            ;
  1646. ;                        ;
  1647. ;-----------------------------------------------;
  1648.  
  1649. @@chk_table    macro
  1650.         call    disp_error_number
  1651.         @@correct_errors
  1652.         @@write_buffer_from_table
  1653.         endm
  1654.  
  1655.  
  1656.  
  1657. ;-----------------------------------------------;
  1658. ;                        ;
  1659. ;    @@crc_check                ;
  1660. ;                        ;
  1661. ;    INPUT :    bl (slant frame's sequence number)
  1662. ;        cx (byte count)            ;
  1663. ;    OUTPUT:    flag                ;
  1664. ;        ( ZR: crc check OK )        ;
  1665. ;    ERROR :    NON                ;
  1666. ;    BREAK :    flags, ax, bx, cx, dx        ;
  1667. ;                        ;
  1668. ;-----------------------------------------------;
  1669.  
  1670. @@crc_check    macro
  1671.         push    si
  1672.         mov    si, offset work_work
  1673.         mov    dx, offset crc_table
  1674.         mov    ax, 0ffffh
  1675.         cmp    byte ptr [si], bl
  1676.         jnz    crc_check_1
  1677.         inc    cx
  1678. crc_check_1:    @@crc_sub
  1679.         cmp    ax, offset ccitt_crc_check
  1680.         pop    si
  1681.         endm
  1682.  
  1683.  
  1684.  
  1685. ;-----------------------------------------------;
  1686. ;                        ;
  1687. ;    @@make_hsi_main                ;
  1688. ;                        ;
  1689. ;    INPUT :    NON                ;
  1690. ;    OUTPUT:    NON                ;
  1691. ;    ERROR :    go_next, ?            ;
  1692. ;    BREAK :    ?                ;
  1693. ;                        ;
  1694. ;-----------------------------------------------;
  1695.  
  1696. @@make_hsi_main    macro
  1697. make_hsi_main:    mov    word ptr work_work2, 0ffffh
  1698. make_hsi_next:    mov    byte ptr type_flag, 0    ; 0 = undetermmined
  1699.                         ; else = '7', '8', 's', 'n'
  1700.         mov    word ptr cmp_done_low, 0
  1701.         mov    word ptr cmp_done_high, 0
  1702.         mov    byte ptr restore_ok, 0
  1703.         mov    sp, offset end_of_stack
  1704.         @@get_header_frame
  1705.         jnz    make_hsi_main
  1706. header_save:    mov    sp, offset end_of_stack
  1707.         mov    byte ptr crc_flag, 0ffh    ; not calculating crc
  1708.         mov    word ptr end_length, 0
  1709.         mov    word ptr end_length2, 0
  1710.         @@header_save
  1711. disp_restore_fname:
  1712.         @@disp_restore_fname
  1713.         @@get_local_time
  1714.         @@check_header
  1715.         @@disp_division
  1716.         @@check_skip_and_create_restore_file
  1717.         @@disp_periods
  1718.         mov    byte ptr seq_old, 0
  1719.         mov    byte ptr error_count, 0
  1720.         @@make_table2            ; loop forever
  1721.         endm
  1722.