Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     .model  small
  2.     .stack  1000h
  3.     .data
  4.  
  5.  
  6. mess        db  'file was opened',10,13,"$"
  7. file        db  'C:\tasm\bin\duzh\test\privet.txt',0
  8. result1     db  'C:\tasm\bin\duzh\test\output.txt',0
  9.  
  10. openfileerror   db  'file did not open',10,13,"$"
  11. savefileerror   db  'file did not save',10,13,"$"
  12. inputerror  db  'You did not input symbol!',10,13,"$"
  13. mesge       db  'Do you want try again?(y/n)',10,13,"$"
  14. outputerror db  'You don`t have text in memory',10,13,"$"
  15.  
  16.  
  17. result      dw  0
  18. valuefirst  dw  0
  19. valuesecond dw  0
  20. handle      dw  0
  21. text        dw  0
  22. first       dw  0
  23. adress      dw  0
  24. schet       dw  0
  25. w       db  10000 dup(0)
  26.  
  27.  
  28.     .code
  29.     .486
  30. extrn   menu:near
  31. extrn   choose:near
  32. extrn   probel:near
  33. public  process
  34. public  inputstring
  35. public  outputstring
  36. public  open
  37. public  close
  38. ;public inputerror
  39. public  finish
  40. public  start
  41. public  input_error
  42. public  cleardump
  43.  
  44. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  45. savefile_error proc
  46.     mov dx, offset savefileerror
  47.     mov ah, 09h
  48.     int 21h
  49.     jmp mes
  50.     ret
  51. savefile_error endp
  52. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  53. openfile_error proc
  54.     mov dx, offset openfileerror
  55.     mov ah, 09h
  56.     int 21h
  57.     jmp mes
  58.     ret
  59. openfile_error  endp
  60. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  61. mes proc
  62.     mov dx, offset mesge
  63.     mov ah, 09h
  64.     int 21h
  65.    
  66.     mov ah, 01h
  67.     int 21h
  68.     cmp al, 79h
  69.     je  start
  70.  
  71.     cmp al, 59h
  72.     je  start
  73.    
  74.     cmp al, 6eh
  75.     je  finish
  76.    
  77.     cmp al, 4eh
  78.     je  finish
  79.     jne mes
  80.     ret
  81. mes endp
  82. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  83. output_error proc
  84.     mov ax, 03h
  85.     int 10h
  86.  
  87.     mov dx, offset outputerror
  88.     mov ah, 09h
  89.     int 21h
  90.  
  91.     call    mes
  92.  
  93.     ret
  94. output_error endp
  95. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  96. input_error proc
  97.     mov ax, 03h
  98.     int 10h
  99.    
  100.     mov dx, offset inputerror
  101.     mov ah, 09h
  102.     int 21h
  103.  
  104.     call    mes
  105.    
  106.     ret
  107. input_error endp
  108. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  109. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  110. savefile proc
  111.     mov ah, 3ch
  112.     mov dx, offset result1
  113.     int 21h
  114.     jc  savefile_error
  115.  
  116.     mov result, ax
  117.     mov bx, ax
  118.  
  119.     mov ah, 40h
  120.     mov dx, offset w
  121.     mov cx, schet
  122.     int 21h
  123.  
  124.     mov ah, 3eh
  125.     mov bx, result
  126.     int 21h
  127.  
  128.     ret
  129. savefile endp
  130. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  131. open_file proc
  132.     mov ax, 3d20h
  133.     mov dx, offset file
  134.     int 21h
  135.  
  136.     jc  openfile_error
  137.  
  138.     mov handle, ax
  139.     mov bx, ax
  140.     mov ah, 3fh
  141.     mov cx, 800h
  142.     mov dx, offset w
  143.     int 21h
  144.     inc ax
  145.     mov schet, ax
  146.     mov adress, ax
  147.     xor ax, ax
  148.     mov cx, schet
  149.  
  150.     mov ah, 3eh
  151.     mov bx, handle
  152.     int 21h
  153.  
  154.     ret
  155. open_file endp
  156. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  157. roww proc
  158.     cmp bx, 16
  159.     jne rowww
  160.    
  161.     add di, 16
  162.     xor bx, bx
  163. rowww:
  164.     ret
  165. roww endp
  166. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  167. derow proc
  168.     cmp bx, 0
  169.     jne deroww
  170.  
  171.     sub di, 16
  172.     add bx, 15
  173. deroww:
  174.     ret
  175. derow endp
  176. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  177. input_star proc
  178.     mov byte ptr w[bx][di], 2ah
  179.     inc bx                 
  180.     dec bp                      ;-bp
  181.     dec cx                      ;-cx
  182.     call    roww
  183.     ret
  184. input_star endp
  185. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  186. input_hyphen proc
  187.     mov byte ptr w[bx][di], 2dh
  188.     inc bx
  189.     sub bp, 2                   ;-3bp
  190.     sub cx, 2               ;-3cx
  191.     call    roww
  192.     ret
  193. input_hyphen endp
  194. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  195. input_hyphen1 proc
  196.     mov byte ptr w[bx][di], 2dh
  197.     inc bx
  198.     dec bp                      ;-bp
  199.     dec cx                      ;-cx
  200.     call    roww
  201.     ret
  202. input_hyphen1 endp
  203. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  204. check_symbol proc
  205.  
  206.    
  207.     cmp ax, 30h
  208.     je  checkk
  209.     cmp ax, 31h
  210.     je  checkk
  211.     cmp ax, 32h
  212.     je  checkk
  213.     cmp ax, 33h
  214.     je  checkk
  215.     cmp ax, 34h
  216.     je  checkk
  217.     cmp ax, 35h
  218.     je  checkk
  219.     cmp ax, 36h
  220.     je  checkk
  221.     cmp ax, 37h
  222.     je  checkk
  223.     cmp ax, 38h
  224.     je  checkk
  225.     cmp ax, 39h
  226.     je  checkk
  227.     jmp symb_checked
  228.  
  229. checkk:
  230.  
  231.     inc si
  232.     jmp true
  233.  
  234. symb_checked:
  235.     xor si, si
  236. true:
  237.    
  238.     ret
  239. check_symbol endp
  240. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  241. replace_4symbols proc
  242.    
  243.     call    derow
  244.     dec bx
  245.     call    derow
  246.     dec bx
  247.     call    derow
  248.     dec bx
  249. ;   call    derow
  250. ;   dec bx
  251.  
  252.     call    roww
  253.     mov byte ptr w[bx][di], 78h
  254.     inc bx
  255.  
  256.     call    roww
  257.     mov byte ptr w[bx][di], 78h
  258.     inc bx
  259.  
  260.     call    roww
  261.     mov byte ptr w[bx][di], 78h
  262.     inc bx
  263.    
  264.     call    roww
  265.     mov byte ptr w[bx][di], 78h
  266.     inc bx
  267.     jmp symbolschanged
  268.  
  269.     ret
  270. replace_4symbols endp
  271. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  272. replace_symbol proc
  273.    
  274.  
  275.     call    roww
  276.     mov byte ptr w[bx][di], 78h
  277.     inc bx
  278.     jmp symbolschanged
  279.     ret
  280. replace_symbol endp
  281. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  282. standart_input proc
  283.     xor ax, ax
  284.     xor bx, bx
  285.     xor cx, cx
  286.     xor dx, dx
  287.     xor bp, bp
  288.     mov di, schet
  289.     mov cx, schet
  290.     ret
  291. standart_input endp
  292. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  293. standart_else proc
  294.     xor ax, ax
  295.     xor bx, bx
  296.     xor cx, cx
  297.     xor dx, dx
  298.     xor di, di
  299.     xor bp, bp
  300.     mov cx, schet
  301.     mov bp, schet
  302.     ret
  303. standart_else endp
  304. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  305. clear_register proc
  306.     xor ax, ax
  307.     xor bx, bx
  308.     xor cx, cx
  309.     xor dx, dx
  310.     xor di, di
  311.     xor si, si
  312.     xor bp, bp
  313.     ret
  314. clear_register endp
  315. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  316. enterstring proc
  317.    
  318. cren:
  319.     call    roww
  320.     mov ah, 01h
  321.     int 21h
  322.    
  323.     cmp al, 1ah
  324.     je  cren3
  325.  
  326.     mov byte ptr w[bx][di], al
  327.     inc bx
  328.     inc bp
  329.    
  330.     cmp al, 0dh
  331.     je  cren1
  332.     jmp cren2
  333. cren1:
  334.     mov ax, 03h
  335.     int 10h
  336.     call    probel
  337.     inc bp
  338. cren2:
  339.     jmp cren
  340. cren3:
  341.     mov byte ptr w[bx][di], 0dh
  342.     inc bx
  343. ;   dec bp
  344.     add schet, bp
  345.    
  346.     ret
  347. enterstring endp
  348. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  349. input_steck proc
  350. steck:
  351.     call    roww
  352.     mov al, byte ptr w[bx][di]
  353.     push    ax
  354.     xor ax, ax
  355.     inc bx
  356.     loop    steck
  357.     jmp root1
  358.     ret
  359. input_steck endp
  360. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  361. output_steck proc
  362.     pop ax
  363.     xor ax, ax
  364.  
  365. steck1:
  366.     pop ax
  367.    
  368.     mov byte ptr w[bx][di], al
  369.     xor ax, ax
  370.     inc bx
  371.     call    roww
  372.     loop    steck1
  373.     jmp root2
  374.     ret
  375. output_steck endp
  376. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  377. input_steck1 proc
  378. steck2:
  379.     call    roww
  380.     mov al, byte ptr w[bx][di]
  381.     push    ax
  382.     xor ax, ax
  383.     inc bx
  384.     loop    steck2
  385.     jmp root3
  386.     ret
  387. input_steck1 endp
  388. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  389. output_string proc
  390. output:
  391.     xor ax, ax
  392.     xor dx, dx
  393.     call    roww
  394.     cmp cx, 0
  395.     je  wasd
  396.     jmp wasd1
  397. wasd:
  398.     call    output_error   
  399. wasd1:
  400.     mov dl, byte ptr w[bx][di]
  401.     inc bx
  402.     cmp dl, 0dh
  403.     je  sdvig
  404.     mov ah, 02h
  405.     int 21h
  406.     jmp sdvig1
  407. sdvig:
  408.     call    probel
  409. sdvig1:
  410.     loop    output
  411.     call    probel
  412.     call    menu
  413.     call    choose
  414.     ret
  415. output_string endp 
  416. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  417. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  418. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  419. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  420. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  421. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  422. Begin:
  423.     mov ax, @data
  424.     mov ds, ax
  425.     call    clear_register
  426.     jmp start
  427. start:
  428.     mov ax, 03h
  429.     int 10h
  430.  
  431.     call    menu
  432.     call    choose
  433.    
  434.                     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  435. inputstring:
  436.     call    standart_input
  437.     call    enterstring
  438.     cmp bp, 0
  439.     je  input_error
  440.  
  441.     mov ax, 03h
  442.     int 10h
  443.     jmp start          
  444.                     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  445. outputstring:
  446.     call    standart_else
  447.     call    output_string
  448.     jmp start
  449.  
  450.                     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  451.  
  452.  
  453. process:
  454.    
  455.     call    standart_else
  456.     cmp cx, 0
  457.     je  input_error
  458.     call    input_steck
  459. root1:
  460.     call    standart_else
  461.     call    output_steck
  462. root2:
  463.     call    standart_else
  464.     call    input_steck1
  465. root3:
  466.     call    standart_else
  467. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  468.  
  469. sort:
  470.    
  471.     pop ax
  472.    
  473.  
  474. sort_space:
  475.     cmp ax, 20h
  476.     je  space
  477.  
  478. sort_dote:
  479.     cmp ax, 2eh
  480.     je  dote1
  481.    
  482.     call    check_symbol
  483.    
  484.  
  485.     cmp si, 4
  486.     je  replace_4symbols
  487.  
  488.     cmp si, 4
  489.     ja  replace_symbol
  490.  
  491.     mov byte ptr w[bx][di], al
  492.     inc bx
  493. symbolschanged:
  494.  
  495.     call    roww
  496.     xor ax, ax
  497.  
  498.     loop    sort
  499.     mov schet, bp
  500.     call    clear_register
  501.     mov cx, schet
  502.     mov di, schet
  503.    
  504. clean2:
  505.    
  506.     call    roww
  507.     mov byte ptr w[bx][di], 00h
  508.     inc bx
  509.     loop    clean2
  510.     jmp start  
  511.  
  512. space:
  513.     xor si, si
  514.     mov byte ptr w[bx][di], 20h
  515.     inc bx
  516.     call    roww
  517.     jmp check_space
  518. space_pop:
  519.     dec cx                  ;-bp
  520.     dec bp                  ;-cx
  521.  
  522. check_space:
  523.     xor ax, ax
  524.     pop ax
  525.     cmp ax, 20h
  526.     je  space_pop
  527.     jne sort_dote
  528.  
  529. dote1:
  530.     xor si, si
  531.     pop ax
  532.    
  533.     cmp ax, 2eh
  534.     je  dote2
  535.     call    input_star              ;-bp ;-cx
  536.     jmp sort_space
  537.  
  538. dote2:
  539.     pop ax
  540.    
  541.     cmp ax, 2eh
  542.     je  dote3
  543.     call    input_star              ;-bp ;-cx
  544.     call    input_star              ;-bp ;-cx
  545.     jmp sort_space
  546.  
  547. dote3:
  548.     pop ax
  549.    
  550.     cmp ax, 2eh
  551.     je  dote4
  552.    
  553.     cmp ax, 2dh
  554.     je  dote31
  555.  
  556.     call    input_hyphen
  557.     jmp sort_space
  558.  
  559. dote31:
  560.     pop ax
  561.     cmp ax, 2dh
  562.     je  dote32
  563.    
  564.     call    input_hyphen   
  565.     call    input_hyphen1
  566.     jmp sort_space
  567.  
  568. dote32:
  569.     pop ax
  570.     cmp ax, 2dh
  571.     je  dote33
  572.     call    input_hyphen   
  573.     call    input_hyphen1
  574.     call    input_hyphen1
  575.     jmp sort_space
  576.  
  577. dote33:
  578.     pop ax
  579.     cmp ax, 2eh
  580.     je  dote331
  581.     call    input_hyphen   
  582.     call    input_hyphen1
  583.     call    input_hyphen1
  584.     call    input_hyphen1
  585.     jmp sort_space
  586.    
  587. dote331:
  588.     pop ax
  589.     cmp ax, 2eh
  590.     je  dote332
  591.     call    input_hyphen   
  592.     call    input_hyphen1
  593.     call    input_hyphen1
  594.     call    input_hyphen1
  595.     call    input_star
  596.     jmp sort_space
  597.  
  598. dote332:
  599.     pop ax
  600.     cmp ax, 2eh
  601.     je  dote333
  602.     call    input_hyphen   
  603.     call    input_hyphen1
  604.     call    input_hyphen1
  605.     call    input_hyphen1
  606.     call    input_star
  607.     call    input_star
  608.     jmp sort_space
  609.  
  610. dote333:
  611.     mov byte ptr w[bx][di], 53h
  612.     inc bx 
  613.     call    roww
  614.     mov byte ptr w[bx][di], 4fh
  615.     inc bx 
  616.     call    roww
  617.     mov byte ptr w[bx][di], 53h
  618.     inc bx 
  619.     call    roww
  620.     sub cx, 6
  621.     sub bp, 5
  622.     jmp sort
  623.  
  624. dote4:
  625.     pop ax
  626.     cmp ax, 2dh
  627.     je  dote41
  628.     cmp ax, 2eh
  629.     je  dote5
  630.     call    input_hyphen
  631.     call    input_star
  632.     jmp sort_space
  633.  
  634. dote5:
  635.     pop ax
  636.     cmp ax, 2dh
  637.     je  dote51
  638.     cmp ax, 2eh
  639.     je  dote6
  640.     call    input_hyphen
  641.     call    input_star
  642.     call    input_star
  643.     jmp sort_space
  644.  
  645. dote6:
  646.     pop ax
  647.     cmp ax, 2dh
  648.     je  dote61
  649.     call    input_hyphen
  650.     call    input_hyphen
  651.     jmp sort
  652.  
  653. dote41:
  654.     call    input_star
  655.     jmp dote31
  656.  
  657. dote51:
  658.     call    input_star
  659.     call    input_star
  660.     jmp dote31
  661. dote61:
  662.     call    input_hyphen
  663.     jmp dote31
  664.  
  665. open:
  666.     call    standart_else
  667.     call    open_file
  668.     jmp start
  669.  
  670. close:
  671.     call    clear_register
  672.     call    savefile
  673.    
  674.    
  675.  
  676. cleardump:
  677.  
  678.     call    clear_register
  679.  
  680.     mov schet, 0
  681.     mov adress, 0
  682.     mov cx, 1000
  683.    
  684.  
  685. clearalldump:
  686.     call    roww
  687.  
  688.     mov byte ptr w[bx][di], 00h
  689.     inc bx
  690.  
  691.     loop    clearalldump
  692.  
  693.     jmp start
  694.  
  695.  
  696.  
  697.    
  698. finish:
  699.     mov bx, schet
  700.     mov ax, 4c00h
  701.     int 21h
  702.     end begin
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement