PhotoShaman

ASM.Лаба9

Apr 29th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; multi-segment executable file template.
  2.  
  3. data segment
  4.     ; add your data here!
  5.     str1 db "Zhukov$"  
  6.     str1Len dw $-str1
  7.     str2 db "Artuom "  
  8.     str2Len dw $-str2
  9.     str3 db "Volodymyrovich "
  10.     str3Len dw $-str3
  11.    
  12.     result db 100 dup(" ")
  13.     length dw ?
  14.     lengthText db 10, 13, "Length: $"
  15.     pkey db 10, 13, "press any key...$"
  16. ends
  17.  
  18. stack segment
  19.     dw   128  dup(0)
  20. ends
  21.  
  22. code segment
  23. start:
  24. ; set segment registers:
  25.     mov ax, data
  26.     mov ds, ax
  27.     mov es, ax
  28.  
  29.     ; add your code here
  30.    
  31.     ;result = str2
  32.     cld
  33.     lea si, str2
  34.     lea di, result
  35.     mov cx, str2Len
  36.     rep movsb  
  37.    
  38.     ;result += str3    
  39.     cld
  40.     lea si, str3
  41.     lea di, result
  42.     add di, str2Len
  43.     mov cx, str3Len
  44.     rep movsb
  45.        
  46.     ;result += str1
  47.     cld
  48.     lea si, str1
  49.     lea di, result
  50.     add di, str2Len
  51.     add di, str3Len
  52.     mov cx, str1Len
  53.     rep movsb    
  54.    
  55.     ;find result length    
  56.     cld
  57.     lea di, result
  58.     mov si, di
  59.     mov cx, 0ffffffffh
  60.     mov al, '$'
  61.     repne scasb
  62.     sub di, si
  63.     dec di
  64.     mov length, di
  65.    
  66.     ;output result
  67.     lea dx, result
  68.     mov ah, 9
  69.     int 21h
  70.    
  71.     ;output result length  
  72.     lea dx, lengthText
  73.     mov ah, 9
  74.     int 21h  
  75.      
  76.     mov ax, length
  77.     call OutInt            
  78.            
  79.     lea dx, pkey
  80.     mov ah, 9
  81.     int 21h        ; output string at ds:dx
  82.    
  83.     ; wait for any key....    
  84.     mov ah, 1
  85.     int 21h
  86.    
  87.     mov ax, 4c00h ; exit to operating system.
  88.     int 21h  
  89.    
  90.     ;Output Int(0 - 99)
  91.     OutInt proc
  92.         aam
  93.         add ax,3030h
  94.         mov dl,ah
  95.         mov dh,al
  96.         mov ah,02
  97.         cmp dl,48   ;is the number starts as 0
  98.         je next
  99.         int 21h
  100.         next:
  101.         mov dl,dh
  102.         int 21h
  103.         ret
  104.     OutInt endp
  105. ends
  106.  
  107. end start ; set entry point and stop the assembler.
Advertisement
Add Comment
Please, Sign In to add comment