Problema 3

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

.

data
formatScanf: .asciz "%s\n"
x:.long 4
y:.long 4
rez:. long 4
chDelim: .asciz " "
str:.asciz "%s\n"
formatPrintf: .asciz "%d\n"
res: .space 4
.text

.global main

main:
pushl $str
pushl $formatScanf
call scanf
popl %ebx
popl %ebx

pushl $chDelim
pushl $str
call strtok
popl %ebx
popl %ebx

movl %eax, res


push res
call atoi
popl %ebx
pushl %eax

et_for:
pushl $chDelim
pushl $0
call strtok
popl %ebx
popl %ebx

cmp $0, %eax


je exit

movl %eax, res


push res
call atoi
popl %ebx

cmp $0, %eax


jne este_numar
pushl %eax

movl res, %edi


xorl %ecx, %ecx
movb (%edi, %ecx, 1), %al
cmp $97, %al
jne et_sub
popl %eax
popl %ebx
addl %eax, %ebx
pushl %ebx
jmp et_for

et_sub:
cmp $115, %al
jne et_mul
popl %eax
popl %ebx
subl %eax, %ebx
pushl %ebx
jmp et_for

et_mul:
cmp $109, %al
jne et_div
popl %eax
popl %ebx
mull %ebx
pushl %eax
jmp et_for

et_div:
cmp $100, %al
jne et_let
popl %eax
popl %ebx
xor %edx,%edx
divl %ebx
pushl %eax
jmp et_for

et_let:
cmp $100, %al
jne et_x
popl x
popl %ebx
jmp et_for

et_x:

cmp $120, %al


jne et_y
cmp $0, x
jne et_1
popl x
popl %ebx
jmp et_for

et_1:
pushl x
jmp et_for

et_y:
cmp $0, y
jne et_2
popl y
popl %ebx
jmp et_for

et_2:
pushl y
jmp et_for

este_numar:
pushl %eax
jmp et_for

exit:
popl rez

pushl rez
pushl $formatPrintf
call printf
popl %ebx
popl %ebx

movl $1, %eax


xorl %ebx, %ebx
int $0x80

You might also like