Advertisement
Vanya_Shestakov

Untitled

Mar 14th, 2021
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. org 100h
  2.         ;output task
  3.         mov ah, 9h
  4.         mov dx, task1
  5.         int 21h
  6.  
  7.         ;output task
  8.         mov ah, 9h
  9.         mov dx, task2
  10.         int 21h
  11.  
  12.         ;output task
  13.         mov ah, 9h
  14.         mov dx, task3
  15.         int 21h
  16.  
  17.         ;output task
  18.         mov ah, 9h
  19.         mov dx, task4
  20.         int 21h
  21.  
  22.         ;input line
  23.         mov ah,0Ah
  24.         mov dx, my_str
  25.         int 21h
  26.  
  27.         ;new line
  28.         mov ah,9h
  29.         mov dx, new_line
  30.         int 21h
  31.  
  32.  
  33.         mov bp, my_str+2 ; address of 1st char
  34.         mov cl,[bp+3] ; 4th char
  35.         mov ch, [bp+5] ; 6th char
  36.  
  37.         ;swap
  38.         xchg ch,cl
  39.         mov [bp+5],ch
  40.         mov [bp+3],cl
  41.  
  42.         ;3rd - (9th - 1st)
  43.         mov ch, [bp+8]
  44.         sub ch, [bp]
  45.         mov cl, [bp+2]
  46.         sub cl, ch
  47.         mov [bp+4], cl
  48.  
  49.         ;output
  50.         mov ah,9h
  51.         mov dx, res_str
  52.         int 21h
  53.  
  54.         ;output res
  55.         mov ah,9h
  56.         mov dx, bp
  57.         int 21h
  58.  
  59.         ;waiting
  60.         mov ah, 8h
  61.         int 21h
  62.  
  63.         ret
  64.  
  65. task1      db "This program swaps fourth and sixth elements of the string" ,$0d,$0a, "$"
  66. task2      db "and performs arithmetic operations with ASKI codes of symbols" ,$0d,$0a, "$"
  67. task3      db "numbered 1, 3, 9 and writes the result to symbol 5" ,$0d,$0a, "$"
  68. task4      db "Input string (max. 10 elements)" ,$0d,$0a, "$"
  69. res_str    db "Result:" ,$0d,$0a, "$"
  70. my_str     db 11,0,11 dup('$')
  71. new_line   db $0d, $0A, "$"                                                                            
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement