Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .data
- matrix: .space 1600
- lineIndex: .space 4
- columnIndex: .space 4
- nr_elem: .space 4
- n: .space 4
- m: .space 4
- res: .space 4
- op1: .space 4
- neg1: .long -1
- sir: .space 400
- formatScanf: .asciz "%[^\n]*400"
- delim: .asciz " "
- printnr: .asciz "%d "
- newline: .asciz "\n"
- .text
- .global main
- main:
- //scanf("[^\n]*400", &sir)
- pushl $sir
- pushl $formatScanf
- call scanf
- popl %ebx
- popl %ebx
- pushl $delim
- pushl $sir
- call strtok
- popl %ebx
- popl %ebx
- //strtok(NULL, " ")
- pushl $delim
- pushl $0
- call strtok
- popl %ebx
- popl %ebx
- pushl %eax
- call atoi
- popl %ebx
- movl %eax, n
- //strtok(NULL, " ")
- pushl $delim
- pushl $0
- call strtok
- popl %ebx
- popl %ebx
- pushl %eax
- call atoi
- popl %ebx
- movl %eax, m
- //index = n * m
- movl n, %eax
- xorl %edx, %edx
- mull m
- movl %eax, nr_elem
- xorl %ecx, %ecx
- et_for:
- cmp %ecx, nr_elem
- je cit_op
- //strtok(NULL, " ")
- pushl %ecx
- pushl $delim
- pushl $0
- call strtok
- popl %ebx
- popl %ebx
- popl %ecx
- pushl %ecx
- pushl %eax
- call atoi
- popl %ebx
- popl %ecx
- movl $matrix, %edi
- movl %eax, (%edi, %ecx, 4)
- incl %ecx
- jmp et_for
- cit_op:
- //citeste let
- //strtok(NULL, " ")
- pushl $delim
- pushl $0
- call strtok
- popl %ebx
- popl %ebx
- //citeste numele matircei
- //strtok(NULL, " ")
- pushl $delim
- pushl $0
- call strtok
- popl %ebx
- popl %ebx
- //citeste operator/rot90d
- //strtok(NULL, " ")
- pushl $delim
- pushl $0
- call strtok
- popl %ebx
- popl %ebx
- movl %eax, res
- pushl %eax
- call atoi
- popl %ebx
- cmp $0, %eax
- je rotire
- movl %eax, op1
- //citeste operatia
- //strtok(NULL, " ")
- pushl $delim
- pushl $0
- call strtok
- popl %ebx
- popl %ebx
- movl %eax, res
- movl res, %esi
- xorl %ecx, %ecx
- xorl %eax, %eax
- movb (%esi, %ecx, 1), %al
- xorl %ecx, %ecx
- cmp $97, %al
- je adunare_for
- cmp $115, %al
- je scadere_for
- cmp $109, %al
- je inmultire_for
- cmp $100, %al
- je impartire_for
- adunare_for:
- cmp nr_elem, %ecx
- je afis_rasp
- movl $matrix, %edi
- movl op1, %eax
- addl %eax, (%edi, %ecx, 4)
- incl %ecx
- jmp adunare_for
- scadere_for:
- cmp nr_elem, %ecx
- je afis_rasp
- movl $matrix, %edi
- movl op1, %eax
- subl %eax, (%edi, %ecx, 4)
- incl %ecx
- jmp scadere_for
- inmultire_for:
- cmp nr_elem, %ecx
- je afis_rasp
- movl $matrix, %edi
- movl (%edi, %ecx, 4), %eax
- xorl %edx, %edx
- imull op1
- movl %eax, (%edi, %ecx, 4)
- incl %ecx
- jmp inmultire_for
- impartire_for:
- cmp nr_elem, %ecx
- je afis_rasp
- cmp $0, op1
- jg op_poz
- //operator negativ
- movl $matrix, %edi
- movl (%edi, %ecx, 4), %eax
- cmp $0, %eax
- jge elempoz_opneg
- //op neg si element din matrice negativ
- xorl %edx, %edx
- imull neg1
- xorl %edx, %edx
- idivl op1
- xorl %edx, %edx
- imull neg1
- movl %eax, (%edi, %ecx, 4)
- incl %ecx
- jmp impartire_for
- elempoz_opneg:
- //op neg si element din matrice pozitiv
- xorl %edx, %edx
- idivl op1
- movl %eax, (%edi, %ecx, 4)
- incl %ecx
- jmp impartire_for
- op_poz:
- //operator pozitiv
- movl $matrix, %edi
- movl (%edi ,%ecx, 4), %eax
- cmp $0, %eax
- jge elempoz
- //op poz si element din matrice negativ
- xorl %edx, %edx
- imull neg1
- xorl %edx, %edx
- idivl op1
- xorl %edx, %edx
- imull neg1
- movl %eax, (%edi, %ecx, 4)
- incl %ecx
- jmp impartire_for
- elempoz:
- //op poz si element din matrice pozitiv
- xorl %edx, %edx
- idivl op1
- movl %eax, (%edi, %ecx, 4)
- incl %ecx
- jmp impartire_for
- rotire:
- pushl m
- pushl $printnr
- call printf
- popl %ebx
- popl %ebx
- pushl n
- pushl $printnr
- call printf
- popl %ebx
- popl %ebx
- movl $0, columnIndex
- subl $1, n
- et_for_col:
- movl columnIndex, %ecx
- cmp m, %ecx
- je et_exit
- movl n, %eax
- movl %eax, lineIndex
- et_for_linii:
- movl lineIndex, %ecx
- cmp $0, %ecx
- jl cont
- //%eax := lineIndex * m + columnIndex
- movl lineIndex, %eax
- xorl %edx, %edx
- mull m
- addl columnIndex, %eax
- movl $matrix, %edi
- pushl (%edi, %eax, 4)
- pushl $printnr
- call printf
- popl %ebx
- popl %ebx
- decl lineIndex
- jmp et_for_linii
- cont:
- incl columnIndex
- jmp et_for_col
- afis_rasp:
- pushl n
- pushl $printnr
- call printf
- popl %ebx
- popl %ebx
- pushl m
- pushl $printnr
- call printf
- popl %ebx
- popl %ebx
- movl $matrix, %edi
- xorl %ecx, %ecx
- parc_mat:
- cmp nr_elem, %ecx
- je et_exit
- pushl %ecx
- pushl (%edi, %ecx, 4)
- pushl $printnr
- call printf
- popl %ebx
- popl %ebx
- popl %ecx
- incl %ecx
- jmp parc_mat
- et_exit:
- pushl $newline
- call printf
- popl %ebx
- movl $1, %eax
- xorl %ebx, %ebx
- int $0x80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement