Created
October 12, 2014 01:41
-
-
Save ramntry/b7aed9c1265964eb2c45 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| program2: runtime.o program2.o | |
| gcc $^ -o $@ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .globl main | |
| .comm var_a, 8 | |
| .comm var_b, 8 | |
| main: xorq %rbx, %rbx | |
| .L0: call runtime_read | |
| .L1: movq %rax, var_a | |
| .L2: call runtime_read | |
| .L3: movq %rax, var_b | |
| .L4: jmp .L18 | |
| .L5: pushq var_a | |
| .L6: movq var_b, %rcx | |
| popq %rax | |
| cqto | |
| idivq %rcx | |
| .L8: movq %rdx, var_a | |
| .L9: pushq var_a | |
| .L10: xorq %rcx, %rcx | |
| popq %rax | |
| cmpq %rcx, %rax | |
| setne %bl | |
| .L12: movq %rbx, %rax | |
| orq %rax, %rax | |
| jz .L18 | |
| .L13: pushq var_b | |
| .L14: movq var_a, %rcx | |
| popq %rax | |
| cqto | |
| idivq %rcx | |
| .L16: movq %rdx, var_b | |
| .L18: pushq var_b | |
| .L19: xorq %rcx, %rcx | |
| popq %rax | |
| cmpq %rcx, %rax | |
| setne %bl | |
| pushq %rbx | |
| .L21: pushq var_a | |
| .L22: xorq %rcx, %rcx | |
| popq %rax | |
| cmpq %rcx, %rax | |
| setne %bl | |
| .L24: movq %rbx, %rcx | |
| andq %rcx, (%rsp) | |
| .L25: popq %rax | |
| orq %rax, %rax | |
| jnz .L5 | |
| .L26: pushq var_a | |
| .L27: movq var_b, %rcx | |
| addq %rcx, (%rsp) | |
| .L29: popq %rdi | |
| call runtime_write | |
| .L30: xorq %rdi, %rdi | |
| call exit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| long long runtime_read() { | |
| long long value = 0; | |
| scanf("%lld", &value); | |
| return value; | |
| } | |
| void runtime_write(long long value) { | |
| printf("%lld\n", value); | |
| } |
ramntry
commented
Oct 12, 2014
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment