Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .data /* секция данных */
- .text /* секция кода программы */
- scanf_4_ints:
- .asciz "%d %d %d %d"
- printf_1_int:
- .asciz "%d\n"
- .global process
- min_max: /* %eax is min, %edx is max */
- pushl %ebp
- movl %esp, %ebp
- movl 8(%ebp), %eax
- movl 12(%ebp), %edx
- cmpl %edx, %eax
- jl less
- greater:
- xorl %eax, %edx /* super swap */
- xorl %edx, %eax
- xorl %eax, %edx
- less:
- movl %ebp, %esp
- popl %ebp
- ret
- process:
- pushl %ebx
- movl $0, %ebx
- pushl %ebp
- movl %esp, %ebp
- subl $16, %esp /* Memory for input data */
- loop:
- leal -16(%ebp), %eax /* Pointers for scanf */
- pushl %eax
- leal -12(%ebp), %eax
- pushl %eax
- leal -8(%ebp), %eax
- pushl %eax
- leal -4(%ebp), %eax
- pushl %eax
- pushl $scanf_4_ints
- call scanf
- cmpl $4, %eax
- jnz end
- addl $16, %esp
- pushl -4(%ebp)
- pushl -12(%ebp)
- call min_max
- movl %edx, -4(%ebp)
- pushl -8(%ebp)
- pushl -16(%ebp)
- call min_max
- movl -4(%ebp), %edx
- subl %edx, %eax
- jnl everything_is_ok
- of:
- movl $0, %eax
- everything_is_ok:
- addl %eax, %ebx
- jmp loop
- end:
- pushl %ebx
- pushl $printf_1_int
- call printf
- movl %ebp, %esp
- popl %ebp
- popl %ebx
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement