StoneHaos

mishar_sist_7

May 3rd, 2021 (edited)
469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. include io.asm
  2.  
  3. sstack segment stack
  4.     db 128 dup(?)
  5. sstack ends
  6.  
  7. sdata segment
  8.     n db 0
  9.     matrix dw 100 dup(0)
  10.  
  11.     inputn db "Input n> ", "$"
  12.     inpute db "Input elements:", 0ah, "$"
  13.     answer db "Answer:", 0ah, "$"
  14.     info db "Negative number: ", "$"
  15.     str_nlargeerror db "n too large!", "$"
  16. sdata ends
  17.  
  18. scode segment
  19. .386
  20.     assume cs:scode, ds:sdata, ss:sstack
  21.  
  22. start:
  23.    
  24.     mov ax,sdata
  25.     mov ds,ax
  26.  
  27.     ; Ввод n
  28.     mov dx,offset inputn
  29.     outstr
  30.     inint ax
  31.     cmp ax,10
  32.     ja nlargeerror
  33.     mov [n],al
  34.  
  35.     mul al
  36.     mov dx,offset inpute
  37.     outstr
  38.  
  39.     ; Ввод матрицы
  40.     mov bx,0
  41.     shl ax,1
  42.     cycle1:
  43.         inint cx
  44.         mov [matrix+bx],cx
  45.         inc bx
  46.         inc bx
  47.         cmp ax,bx
  48.         jne cycle1
  49.  
  50.     ; Вывод матрицы
  51.     mov cx,0
  52.     mov cl,[n]
  53.     mov bx,0
  54.     cycle2_1:
  55.         push cx
  56.         mov cl,[n]
  57.         cycle2_2:
  58.             outint [matrix+bx]
  59.             outch " "
  60.             inc bx
  61.             inc bx
  62.             loop cycle2_2
  63.         pop cx
  64.         newline
  65.         loop cycle2_1
  66.  
  67.     ; Вывод ответа
  68.     newline
  69.     mov dx,offset answer
  70.     outstr
  71.  
  72.     mov ax,0 ; Индекс строки
  73.     mov bx,0 ; Линейное смещение
  74.     mov cx,0 ; Индекс столбца
  75.     cycle3_1:
  76.         cycle3_2:
  77.             mov dx,[matrix+bx]
  78.             cmp dx,0
  79.             jge cycle3_2_else1
  80.             mov dx,offset info
  81.             outstr
  82.             outint ax
  83.             outch ","
  84.             outint cx
  85.             newline
  86.  
  87.             cycle3_2_else1:
  88.             inc bx
  89.             inc bx
  90.             inc cx
  91.             cmp cl,[n]
  92.             jne cycle3_2
  93.         inc ax
  94.         xor cx,cx
  95.         cmp al,[n]
  96.         jne cycle3_1
  97.  
  98.     jmp endstart
  99.  
  100. nlargeerror:
  101.     mov dx,offset str_nlargeerror
  102.     outstr
  103.    
  104.  
  105. endstart:
  106.     finish
  107. scode ends
  108. end start
Add Comment
Please, Sign In to add comment