Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;Alexey Berezin 113  may 6, 2010
  2. ;в тексте больше 3 латинских букв
  3. ;1)Заменить каждую заглавную латинскую букву на заглавную букву, симметричную ей в алфавите (A  Z, B  Y, ...).
  4. ;2) Перевернуть текст, не используя дополнительную память.
  5.  
  6. include io.asm ;подключение операций ввода-вывода
  7.  
  8. stack segment stack
  9.     db 256 dup (?)
  10. stack ends
  11.  
  12. data segment
  13. ; место для переменных и констант
  14.     N equ 200
  15.     Str db N
  16. data ends
  17.  
  18. code segment 'code'
  19.     assume ss:stack, ds:data, cs:code
  20. ; место для описания процедур
  21. CHECK proc ; Di- length,  
  22.    
  23.     mov Cx, DI
  24.     xor SI,SI
  25.     xor Dx,Dx
  26.     JCXZ cxzero
  27.  L1: mov DL, Str[SI]
  28.      inc SI
  29.      cmp DL, 'A'
  30.      JB con1
  31.      cmp DL,'z'
  32.      JA con1
  33.      cmp DL,'Z'; from A to Z
  34.      JBE add1
  35.      cmp DL,'a'; from a to z
  36.      JAE add1
  37.      JMP con1
  38.     add1: inc DH ;dh-number of Eng letters
  39.      con1:
  40.   loop L1
  41.  
  42.   cxzero:  mov AL, 1
  43.   cmp DH,3
  44.   JG EN1
  45.     inc AL
  46.   EN1:
  47.  
  48.   mov AH,0
  49.   outint Ax
  50.  
  51.  ret
  52.  CHECK endp
  53.  
  54.  
  55.  STR_F1 proc
  56.   ;if x in {UPPER CASE} then x->'Z'-x+'A'
  57.  
  58.     mov Cx, DI
  59.     xor SI,SI
  60.  L2: mov DL, Str[SI]
  61.      cmp DL, 'A'
  62.      JB con2
  63.      cmp DL,'Z'
  64.      JA con2
  65.      neg DL
  66.      ADD DL,'Z'+'A'
  67.      mov Str[SI], DL
  68.     con2: inc SI
  69.  loop L2
  70.     ret
  71.  STR_F1 endp
  72.    
  73.  STR_F2 proc
  74.     push DI
  75.    
  76.     dec DI
  77.     xor SI,SI
  78.  L3: cmp SI,DI
  79.      JNL con3
  80.      mov DL, Str[SI]
  81.      mov DH, Str[DI]
  82.      mov Str[SI], DH
  83.      mov Str[DI], DL
  84.      dec DI
  85.      inc SI
  86.      JMP L3
  87.  con3:
  88.     pop DI
  89.     ret
  90.  STR_F2 endp
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  start:
  97.     mov Ax,data
  98.     mov Ds,Ax
  99. ;input text
  100.     mov Cx, N
  101.     xor DI,DI
  102.  rd1: inch AL
  103.         cmp Al,'.'
  104.         JE ChkStr
  105.         mov Str[DI],AL
  106.         inc DI
  107.     loop rd1
  108.  
  109. ChkStr: newline ; to comment
  110.     outword DI;to comment
  111.     newline;
  112.     mov CX,DI
  113. JCXZ cxzero2
  114. xor SI,SI
  115. wr1:outch   Str[SI]
  116.     inc SI
  117.     loop wr1
  118.     newline
  119. cxzero2:
  120.  ;ChkStr
  121.     call CHECK
  122.   cmp AL, 1
  123.   jne sol2
  124.     call STR_F1
  125.     jmp next
  126.   sol2: call STR_F2
  127.  
  128.  next:
  129.   newline
  130.  
  131.   mov Cx,DI
  132.  JCXZ cxzero3
  133.   xor SI, SI
  134.   for3: outch Str[SI]
  135.     inc SI
  136.     loop for3
  137.  cxzero3: newline
  138.     finish
  139. code ends
  140.     end start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement