Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .section .rodata
- scn_fmt:
- .string "%d%d%d%d"
- pnt_fmt:
- .string "%d\n"
- .data
- sum: .int 0
- .text
- .global process
- process:
- pushl %ebp
- movl %esp, %ebp
- loop_start_:
- leal -4(%esp), %eax
- pushl %eax
- leal -4(%esp), %eax
- pushl %eax
- leal -4(%esp), %eax
- pushl %eax
- leal -4(%esp), %eax
- pushl %eax
- pushl $scn_fmt
- call scanf
- addl $20, %esp
- cmpl $4, %eax
- jnz finish_
- movl $0, %eax
- addl -12(%esp), %eax /* b1 */
- subl -16(%esp), %eax /* a1 */
- addl -4(%esp), %eax /* b2 */
- subl -8(%esp), %eax /* a2 */
- /* addl %eax, sum */
- movl -12(%esp), %ecx
- cmpl -4(%esp), %ecx /* b1 - b2 */
- jl take_b2_
- cnt1_:
- subl %ecx, %eax
- movl -16(%esp), %ecx
- cmpl -8(%esp), %ecx /* a1 - a2 */
- jg take_a2_
- cnt2_:
- addl %ecx, %eax
- cmpl $0, %eax
- jg add_sum_
- jmp loop_start_
- finish_:
- pushl sum
- pushl $pnt_fmt
- call printf
- addl $8, %esp
- popl %ebp
- ret
- take_b2_:
- movl -4(%esp), %ecx
- jmp cnt1_
- take_a2_:
- movl -8(%esp), %ecx
- jmp cnt2_
- add_sum_:
- addl %eax, sum
- jmp loop_start_
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement