Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .data
- sirhex: .space 100
- codOp: .long 0
- nr: .space 4
- cifra2: .long 0
- cifra: .long 0
- nrPoz: .long 0
- nrNeg: .long 0
- op: .long 0
- var: .long 0
- formatScanf: .asciz "%s"
- newline: .asciz "\n"
- //neg: .long -1
- minus: .asciz "-"
- let: .asciz "let "
- sum: .asciz "add "
- dif: .asciz "sub "
- inmul: .asciz "mul "
- imp: .asciz "div "
- afisVariabila: .asciz "%c "
- afisNumar: .asciz "%d "
- .text
- .global main
- main:
- //scanf("%s", &s)
- pushl $sirhex
- pushl $formatScanf
- call scanf
- popl %ebx
- popl %ebx
- movl $sirhex, %edi
- movl $0, %ecx
- et_for:
- //identificator
- movb (%edi, %ecx, 1), %al
- cmp $0, %al
- je et_exit
- movl $0, nrPoz
- movl $0, nrNeg
- movl $0, op
- movl $0, var
- cmp $56, %al #8 -> numar pozitiv
- je nr_poz
- cmp $57, %al #9 -> numar negativ
- je nr_neg
- cmp $67, %al #C -> operatie
- je operatie
- cmp $65, %al #A -> variabila
- je variabila
- nr_poz:
- movl $1, nrPoz
- jmp cont
- nr_neg:
- movl $1, nrNeg
- jmp cont
- operatie:
- movl $1, op
- jmp cont
- variabila:
- movl $1, var
- jmp cont
- cont:
- incl %ecx
- movl $0, cifra2
- movl $0, codOp
- movb (%edi, %ecx, 1), %al
- cmp $0, %al
- je et_exit
- calcOp:
- movl %eax, cifra
- pushl %eax
- cmp $1, cifra2
- je adaug1
- movl $16, %eax
- jmp compara
- adaug1:
- movl $1, %eax
- compara:
- cmp $48, cifra
- je cif0
- cmp $49, cifra
- je cif1
- cmp $50, cifra
- je cif2
- cmp $51, cifra
- je cif3
- cmp $52, cifra
- je cif4
- cmp $53, cifra
- je cif5
- cmp $54, cifra
- je cif6
- cmp $55, cifra
- je cif7
- cmp $56, cifra
- je cif8
- cmp $57, cifra
- je cif9
- cmp $65, cifra
- je cif10
- cmp $66, cifra
- je cif11
- cmp $67, cifra
- je cif12
- cmp $68, cifra
- je cif13
- cmp $69, cifra
- je cif14
- cmp $70, cifra
- je cif15
- cif0:
- movl $0, nr
- mull nr
- jmp cont2
- cif1:
- movl $1, nr
- mull nr
- jmp cont2
- cif2:
- movl $2, nr
- mull nr
- jmp cont2
- cif3:
- movl $3, nr
- mull nr
- jmp cont2
- cif4:
- movl $4, nr
- mull nr
- jmp cont2
- cif5:
- movl $5, nr
- mull nr
- jmp cont2
- cif6:
- movl $6, nr
- mull nr
- jmp cont2
- cif7:
- movl $7, nr
- mull nr
- jmp cont2
- cif8:
- movl $8, nr
- mull nr
- jmp cont2
- cif9:
- movl $9, nr
- mull nr
- jmp cont2
- cif10:
- movl $10, nr
- mull nr
- jmp cont2
- cif11:
- movl $11, nr
- mull nr
- jmp cont2
- cif12:
- movl $12, nr
- mull nr
- jmp cont2
- cif13:
- movl $13, nr
- mull nr
- jmp cont2
- cif14:
- movl $14, nr
- mull nr
- jmp cont2
- cif15:
- movl $15, nr
- mull nr
- jmp cont2
- cont2:
- addl %eax, codOp
- popl %eax
- cmp $1, cifra2 #verific daca sunt la prima sau a doua cifra hex din codificarea operatiei
- je afOp #daca sunt la a doua cifra afisez operatia
- movl $1, cifra2
- incl %ecx
- movb (%edi, %ecx, 1), %al
- cmp $0, %al
- je et_exit
- jmp calcOp #adaug si a doua cifra hex la coficarea operatiei
- afOp:
- cmp $1, nrPoz
- je afNrPoz
- cmp $1, nrNeg
- je afNrNeg
- cmp $1, op
- je afisOp
- cmp $1, var
- je afVar
- afNrPoz:
- //printf("%d ", codOp)
- pushl %eax
- pushl %ecx
- pushl codOp
- pushl $afisNumar
- call printf
- popl %ebx
- popl %ebx
- popl %ecx
- popl %eax
- jmp cont3
- afNrNeg:
- //pushl %eax
- //movl codOp, %eax
- //imull neg
- //movl %eax, codOp
- //popl %eax
- pushl %eax
- pushl %ecx
- pushl $minus
- call printf
- popl %ebx
- popl %ecx
- popl %eax
- //printf("%d ", codOp)
- pushl %eax
- pushl %ecx
- pushl codOp
- pushl $afisNumar
- call printf
- popl %ebx
- popl %ebx
- popl %ecx
- popl %eax
- jmp cont3
- afisOp:
- cmp $0, codOp
- je afLet
- cmp $1, codOp
- je afAdd
- cmp $2, codOp
- je afSub
- cmp $3, codOp
- je afMul
- cmp $4, codOp
- je afDiv
- afLet:
- pushl %eax
- pushl %ecx
- pushl $let
- call printf
- popl %ebx
- popl %ecx
- popl %eax
- jmp cont3
- afAdd:
- pushl %eax
- pushl %ecx
- pushl $sum
- call printf
- popl %ebx
- popl %ecx
- popl %eax
- jmp cont3
- afSub:
- pushl %eax
- pushl %ecx
- pushl $dif
- call printf
- popl %ebx
- popl %ecx
- popl %eax
- jmp cont3
- afMul:
- pushl %eax
- pushl %ecx
- pushl $inmul
- call printf
- popl %ebx
- popl %ecx
- popl %eax
- jmp cont3
- afDiv:
- pushl %eax
- pushl %ecx
- pushl $imp
- call printf
- popl %ebx
- popl %ecx
- popl %eax
- jmp cont3
- afVar:
- //printf("%c ", codOp)
- pushl %eax
- pushl %ecx
- pushl codOp
- pushl $afisVariabila
- call printf
- popl %ebx
- popl %ebx
- popl %ecx
- popl %eax
- jmp cont3
- cont3:
- incl %ecx
- jmp et_for
- et_exit:
- //printf("\n")
- pushl %ecx
- pushl $newline
- call printf
- popl %ebx
- popl %ecx
- movl $1, %eax
- xorl %ebx, %ebx
- int $0x80
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement