Advertisement
Guest User

Untitled

a guest
Nov 3rd, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; multi-segment executable file template.
  2. ;preku procedura od golemi vo mali
  3. data segment
  4.    ; add your data here!
  5.     message1 db "Vnesi stringA:$"
  6.     message2 db "Vnesi stringB:$"
  7.     newLine db 10,13,"$"
  8.    
  9.     stringA db ?,?,?,?,?,?,?,?  
  10.     stringB db ?,?,?,?,?,?,?,?    
  11.    
  12.    
  13.     modifiedA db ?,?,?,?,?,?,?,?
  14.     modifiedB db ?,?,?,?,?,?,?,?
  15.                                  
  16.     counter dw 0                
  17.     counter2 dw 0
  18.      
  19.     transformations db 0        
  20.    
  21.     pok dw 0          
  22.     pok2 dw 0
  23.    
  24.     flag db 0                      
  25.    
  26.    
  27.     messageIsti db "Isti se $"
  28.     messageRazlicni db "Razlicni se $"
  29.    
  30.      
  31. ends
  32.  
  33. stack segment
  34.     dw   128  dup(0)
  35. ends            
  36.  
  37.  
  38. code segment
  39.    
  40.    
  41. transform proc
  42. mov cx,counter
  43. pop bx
  44. checking:
  45. cmp cx,0d
  46. je forward
  47. pop ax
  48.  
  49.  
  50. cmp ax,5Bh
  51. jl isBigNumber
  52. dec cx
  53. jmp checking
  54.  
  55. isBigNumber:
  56. add ax,20h
  57. push ax
  58. add sp,2  
  59. dec cx
  60. inc transformations
  61.  
  62. jmp checking          
  63.                  
  64. push bx    
  65. ret
  66. transform endp
  67.  
  68.  
  69.  
  70. start:
  71. ; set segment registers:
  72.     mov ax, data
  73.     mov ds, ax
  74.     mov es, ax
  75.  
  76. ; add your code here      
  77.     lea dx,message1
  78.     mov ah,09h
  79.     int 21h    
  80.    
  81.     insertA:
  82.     mov ah,01h
  83.     int 21h
  84.     cmp al,"$"
  85.     je continue
  86.     mov stringA[si],al
  87.     inc si          
  88.     inc counter
  89.     loop insertA  
  90.          
  91.          
  92.     continue:
  93.     mov ah,09h
  94.     lea dx,newLine
  95.     int 21h          
  96.     mov si,0h
  97.                
  98.                
  99.     lea dx,message2
  100.     mov ah,09
  101.     int 21h
  102.                
  103.    
  104.     insertB:
  105.     mov ah,01h
  106.     int 21h
  107.     cmp al,"$"
  108.     je go
  109.     mov stringB[si],al
  110.     inc si  
  111.     inc counter2
  112.     loop insertB  
  113.          
  114.          
  115.          
  116.     go:
  117.    ;TRANSFORMING STRING A
  118.     mov si,0h
  119.     mov cx,counter
  120.     pop1:
  121.     mov dl,stringA[si]
  122.     mov dh,0h
  123.     push dx
  124.     inc si
  125.     loop pop1
  126.    
  127.     call transform
  128.    
  129.     ;GettingModifiedA
  130.     forward:
  131.     cmp flag,0h
  132.     jg modifyB
  133.     inc flag
  134.    ;;postavuvanje na pokazuvacot
  135.     mov si,counter  
  136.     sub si,01d
  137.     mov cx,counter
  138.     mov ax,0d
  139.     mov ax,counter
  140.     mov bl,2d
  141.     mul bl
  142.     mov pok,ax
  143.     sub sp,pok
  144.  
  145.     get1:            
  146.     pop dx              
  147.     mov dh,0h          
  148.     mov modifiedA[si],dl
  149.     dec si
  150.     loop get1        
  151.  
  152.    
  153.    
  154.     ;;GettingModifiedB
  155.  
  156.     ;TRANSFORMING STRING A
  157.    
  158.     mov si,0h
  159.     mov cx,counter2
  160.     pop2:
  161.     mov dl,stringB[si]
  162.     mov dh,0h
  163.     push dx
  164.     inc si
  165.     loop pop2
  166.  
  167.     call transform
  168.     modifyB:
  169.    ;;postavuvanje na pokazuvacot
  170.     mov si,counter2  
  171.     sub si,01d
  172.     mov cx,counter2
  173.     mov ax,0d
  174.     mov ax,counter2
  175.     mov bl,2d
  176.     mul bl
  177.     mov pok2,ax
  178.     sub sp,pok2
  179.  
  180.     get2:            
  181.     pop dx              
  182.     mov dh,0h          
  183.     mov modifiedB[si],dl
  184.     dec si
  185.     loop get2        
  186.  
  187.    
  188.     ;;Sega final za sporedba dali se ednakvi
  189.    
  190.    
  191.     mov cx,counter
  192.     mov si,0d
  193.     putInStack:
  194.     mov dx,0d
  195.     mov dl,modifiedA[si]
  196.     push dx
  197.     inc si
  198.     loop putInStack
  199.    
  200.    
  201.    
  202.     mov cx,counter2
  203.     mov si,counter2
  204.     sub si,01d
  205.     listInB:
  206.     cmp cx, 0d
  207.     je print1
  208.     mov bl,modifiedB[si]
  209.     pop dx  
  210.     dec cx        
  211.     dec si
  212.     cmp bl,dl
  213.     je listInB
  214.     jmp print2  
  215.    
  216.    
  217.     print1:
  218.     lea dx,messageIsti
  219.     mov ah,09h
  220.     int 21h
  221.     jmp finishing
  222.    
  223.     print2:
  224.     lea dx,messageRazlicni
  225.     mov ah,09h
  226.     int 21h      
  227.     jmp finishing
  228.    
  229.    
  230.     finishing:
  231.     endp
  232.    
  233.    
  234. end start ; set entry point and s
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement