Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include io.asm
- sstack segment stack
- db 128 dup(?)
- sstack ends
- sdata segment
- n db 0
- matrix dw 100 dup(0)
- inputn db "Input n> ", "$"
- inpute db "Input elements:", 0ah, "$"
- answer db "Answer:", 0ah, "$"
- info db "Negative number: ", "$"
- str_nlargeerror db "n too large!", "$"
- sdata ends
- scode segment
- .386
- assume cs:scode, ds:sdata, ss:sstack
- start:
- mov ax,sdata
- mov ds,ax
- ; Ввод n
- mov dx,offset inputn
- outstr
- inint ax
- cmp ax,10
- ja nlargeerror
- mov [n],al
- mul al
- mov dx,offset inpute
- outstr
- ; Ввод матрицы
- mov bx,0
- shl ax,1
- cycle1:
- inint cx
- mov [matrix+bx],cx
- inc bx
- inc bx
- cmp ax,bx
- jne cycle1
- ; Вывод матрицы
- mov cx,0
- mov cl,[n]
- mov bx,0
- cycle2_1:
- push cx
- mov cl,[n]
- cycle2_2:
- outint [matrix+bx]
- outch " "
- inc bx
- inc bx
- loop cycle2_2
- pop cx
- newline
- loop cycle2_1
- ; Вывод ответа
- newline
- mov dx,offset answer
- outstr
- mov ax,0 ; Индекс строки
- mov bx,0 ; Линейное смещение
- mov cx,0 ; Индекс столбца
- cycle3_1:
- cycle3_2:
- mov dx,[matrix+bx]
- cmp dx,0
- jge cycle3_2_else1
- mov dx,offset info
- outstr
- outint ax
- outch ","
- outint cx
- newline
- cycle3_2_else1:
- inc bx
- inc bx
- inc cx
- cmp cl,[n]
- jne cycle3_2
- inc ax
- xor cx,cx
- cmp al,[n]
- jne cycle3_1
- jmp endstart
- nlargeerror:
- mov dx,offset str_nlargeerror
- outstr
- endstart:
- finish
- scode ends
- end start
Add Comment
Please, Sign In to add comment