home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / tools / asmflo / file1.asm < prev    next >
Assembly Source File  |  1988-04-05  |  6KB  |  237 lines

  1. title   ASMFLOW_sample_source_file
  2.  
  3. dosseg
  4.  
  5. .model small
  6.  
  7. .code
  8.  
  9. EXTRN edit_warning             : near
  10. EXTRN insert_blank_line        : near
  11. EXTRN adjust_line_misspellings : near
  12.  
  13. ; some code samples to show flow charting and
  14. ; tree diagram features of ASMFLOW
  15.  
  16.  
  17. PUBLIC join_lines
  18. join_lines PROC near
  19.  
  20.               push   cx
  21.               push   dx
  22.               push   si
  23.               push   di
  24.  
  25.               mov    ax, bp
  26.               sar    ax, 1
  27.               inc    ax
  28.               cmp    ax, edit_num_lines
  29.               jl     jl_0
  30.               jmp    jl_x
  31. jl_0:
  32.               mov    dx, ds:edit_line_nc[bp]
  33.               sub    dx, eol_nc
  34.               add    dx, ds:edit_line_nc[bp+2]
  35.               cmp    dx, max_line_length
  36.               jle    jl_1
  37.               mov    al, .ew_join_ln_max_len
  38.               call   edit_warning
  39.               jmp    jl_x
  40. jl_1:
  41.               mov    cx, ds:edit_line_nc[bp+2]
  42.               push   cx                       ; save num chars next line
  43.               push   ax                       ; save next line number
  44.               mov    dx, 0
  45.               mul    max_line_length
  46.               mov    si, ax                   ; offset to start next line
  47.               mov    di, bx
  48. jl_loop_1:
  49.               mov    al, edit_buffer[si]
  50.               mov    edit_buffer[di], al
  51.               inc    si
  52.               inc    di
  53.               loop   jl_loop_1
  54.  
  55. ; adjust misspelling ptrs for joined line
  56.  
  57.               push   bp
  58.               add    bp, 2
  59.               mov    dx, ds:edit_line_nc[bp-2]
  60.               sub    dx, eol_nc
  61.               sub    dx, max_line_length      ; amount to add (neg so subtract)
  62.               call   adjust_line_misspellings
  63.               pop    bp
  64.  
  65. ; delete next line
  66.  
  67.               pop    ax                       ; next line number
  68.               call   delete_edit_line
  69.  
  70. ; update number characters for joined line
  71.  
  72.               pop    cx                       ; num chars line appended
  73.               add    cx, ds:edit_line_nc[bp]
  74.               sub    cx, eol_nc               ; eol chars are overlayed
  75.               mov    ds:edit_line_nc[bp], cx
  76.  
  77. ; update display from joined line to last line
  78.  
  79.               mov    ax, bp
  80.               sar    ax, 1
  81.               mov    cx, edit_num_lines
  82.               sub    cx, ax
  83.               inc    cx
  84. jl_loop_3:
  85.               call   edit_line_out
  86.               inc    ax
  87.               loop   jl_loop_3
  88. jl_x:
  89.               pop    di
  90.               pop    si
  91.               pop    dx
  92.               pop    cx
  93.               ret
  94.  
  95. join_lines ENDP
  96.  
  97.  
  98. PUBLIC break_current_line
  99. break_current_line PROC
  100.  
  101.               push   cx
  102.               push   dx
  103.               push   di
  104.               push   si
  105.  
  106.               mov    dx, 0
  107.               mov    ax, bx
  108.               div    max_line_length
  109.               mov    cx, ds:edit_line_nc[bp]
  110.               sub    cx, dx
  111.               cmp    cx, eol_nc
  112.               jg     bcl_0
  113.               mov    al, .ew_brk_line_aft_eol
  114.               call   edit_warning
  115.               jmp    bcl_x
  116.  
  117. bcl_0:
  118.              push    ax
  119.              mov     ax, edit_num_lines
  120.              cmp     ax, edit_max_num_lines
  121.              jl      bcl_1
  122.              pop     ax
  123.              mov     al, .ew_brk_line_max_ln
  124.              call    edit_warning
  125.              jmp     bcl_x
  126.  
  127. bcl_1:
  128.              mov     ax, bp
  129.              sar     ax, 1
  130.              inc     ax
  131.              call    insert_blank_line
  132.  
  133.              pop     ax
  134.              push    dx
  135.              mov     ds:edit_line_nc[bp+2], cx
  136.              add     dx, eol_nc
  137.              mov     ds:edit_line_nc[bp], dx
  138.              inc     ax
  139.              mul     max_line_length
  140.              mov     di, ax                  ; offset to start next line
  141.              mov     si, bx
  142.              pop     dx
  143.              push    ax                      ; save offset to next line
  144. bcl_loop_1:
  145.              mov     al, edit_buffer[si]
  146.              mov     edit_buffer[si], ' '
  147.              mov     edit_buffer[di], al
  148.              inc     si
  149.              inc     di
  150.              loop    bcl_loop_1
  151.  
  152. ;      update offsets for misspellings on new line
  153.  
  154.              mov     ax, max_line_length
  155.              sub     ax, dx
  156.              mov     dx, ax
  157.              call    adjust_line_misspellings
  158.              call    join_lines
  159.  
  160. ;      add eol characters to end of current line
  161. ;      update cursor position to start of next line
  162.  
  163.              mov     cx, eol_nc
  164.              mov     si, 0
  165.              mov     di, bx
  166. bcl_loop_2:
  167.              mov     al, eol_chars[si]
  168.              mov     edit_buffer[di], al
  169.              inc     si
  170.              inc     di
  171.              loop    bcl_loop_2
  172.              pop     bx                    ; saved offset to start next line
  173.  
  174. ;  update display from current line to end of edit lines
  175.  
  176.              mov     ax, bp
  177.              sar     ax, 1
  178.              mov     cx, edit_num_lines
  179.              sub     cx, ax
  180. bcl_loop_3:
  181.              call    edit_line_out
  182.              inc     ax
  183.              loop    bcl_loop_3
  184. bcl_x:
  185.              call    join_lines
  186.              ret
  187.              pop     si
  188.              pop     di
  189.              pop     dx
  190.              pop     cx
  191.              ret
  192.  
  193. break_current_line ENDP
  194.  
  195.  
  196. ; demo of more complex branching for flow chart
  197.  
  198. nonsense proc near
  199.  
  200.        push cx
  201.  
  202.        mov  cx, 10
  203.        cmp  ax, -1
  204. top1:
  205.        je   down1
  206.        cmp  ax, 0
  207. up1:
  208.        jc   down1
  209.        je   down2
  210.        inc  ax
  211.        jz   down3
  212.        inc  ax
  213.        jz   down1
  214.        inc  cx
  215. down1:
  216.        cmp  cx, 2
  217.        jc   down2
  218.        je   up1
  219.        inc  ax
  220.        jz   down2
  221.        jc   down3
  222.        add  ax, bx
  223. down2:
  224.        jc   down4
  225.        inc  cx
  226. down3:
  227.        loop top1
  228. up2:
  229.        ret
  230.        ret
  231. down4:
  232.        jmp  up2
  233.  
  234. nonsense endp
  235.  
  236.          end
  237.