Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .data
- sir: .space 400
- res: .space 4
- atoiRes: .space 4
- op1: .space 4
- variabile: .space 200
- nume_var: .space 4
- valoare: .space 4
- formatScanf: .asciz "%[^\n]*400"
- printnr: .asciz "%d\n"
- delim: .asciz " "
- .text
- .global main
- main:
- movl $variabile, %edi
- xorl %ecx, %ecx
- init:
- cmp $26, %ecx
- je incepe
- movl $-1, %eax
- movl %eax, (%edi, %ecx, 4)
- incl %ecx
- jmp init
- incepe:
- //scanf("%[^\n]*400", sir)
- pushl $sir
- pushl $formatScanf
- call scanf
- popl %ebx
- popl %ebx
- //strtok(sir, " ")
- pushl $delim
- pushl $sir
- call strtok
- popl %ebx
- popl %ebx
- movl %eax, res
- pushl res
- call atoi
- popl %ebx
- movl %eax, atoiRes
- cmp $0, atoiRes
- je var1
- pushl atoiRes
- jmp et_for
- var1:
- pushl res
- et_for:
- pushl $delim
- pushl $0
- call strtok
- popl %ebx
- popl %ebx
- movl %eax, res
- cmp $0, res
- je et_exit
- pushl res
- call atoi
- popl %ebx
- movl %eax, atoiRes
- cmp $0, atoiRes
- je operatie_sau_var
- pushl atoiRes
- jmp et_for
- operatie_sau_var:
- movl res, %edi
- xorl %eax, %eax
- xorl %ebx, %ebx
- xorl %ecx, %ecx
- movb (%edi, %ecx, 1), %al
- incl %ecx
- movb (%edi, %ecx, 1), %ah
- cmpb $0, %ah
- jne operatie
- verif_exist:
- movl $variabile, %edi
- subl $97, %eax
- movl %eax, %ecx
- movl (%edi, %ecx, 4), %ebx
- cmp $-1, %ebx
- jne var_exista
- cont2:
- pushl res
- jmp et_for
- var_exista:
- movl (%edi, %ecx, 4), %eax
- pushl %eax
- jmp et_for
- operatie:
- cmp $97, %al
- je adunare
- cmp $115, %al
- je scadere
- cmp $109, %al
- je inmultire
- cmp $100, %al
- je impartire
- cmp $108, %al
- je atribuire
- adunare:
- popl op1
- popl %eax
- addl op1, %eax
- pushl %eax
- jmp et_for
- scadere:
- popl op1
- popl %eax
- subl op1, %eax
- pushl %eax
- jmp et_for
- inmultire:
- popl op1
- popl %eax
- mull op1
- pushl %eax
- jmp et_for
- impartire:
- popl op1
- popl %eax
- xorl %edx, %edx
- divl op1
- pushl %eax
- jmp et_for
- atribuire:
- movl $variabile, %edi
- popl valoare
- popl nume_var
- movl nume_var, %esi
- xorl %ecx, %ecx
- xorl %eax, %eax
- movb (%esi, %ecx, 1), %al
- subl $97, %eax
- movl %eax, %ecx
- movl valoare, %eax
- movl %eax, (%edi, %ecx, 4)
- jmp et_for
- et_exit:
- pushl $printnr
- call printf
- popl %ebx
- popl %ebx
- movl $1, %eax
- xorl %ebx, %ebx
- int $0x80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement