Professional Documents
Culture Documents
Problema 3
Problema 3
Problema 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
et_for:
pushl $chDelim
pushl $0
call strtok
popl %ebx
popl %ebx
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:
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