Mercurial > hg > y16 > e165730 > Compiler > Ex4.1
changeset 0:599aae9aca01
add assembler program
author | e165730 |
---|---|
date | Thu, 14 Feb 2019 21:45:47 +0900 |
parents | |
children | 7a3228903d87 |
files | ex4-1-1.s ex4-1-2.s |
diffstat | 2 files changed, 102 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ex4-1-1.s Thu Feb 14 21:45:47 2019 +0900 @@ -0,0 +1,41 @@ + .section __TEXT,__text,regular,pure_instructions + .build_version macos, 10, 14 + .globl _main ## -- Begin function main + .p2align 4, 0x90 +_main: ## @main + .cfi_startproc +## %bb.0: + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset %rbp, -16 + movq %rsp, %rbp + .cfi_def_cfa_register %rbp + subq $16, %rsp + leaq L_.str(%rip), %rdi + + movq $2, %rax + pushq %rax + movq $4, %rax + popq %rbx + subq %rbx, %rax + pushq %rax + movq $3, %rax + popq %rbx + subq %rbx, %rax + + movq %rax, %rsi + callq _printf + xorl %esi, %esi + movl %eax, -12(%rbp) ## 4-byte Spill + movl %esi, %eax + addq $16, %rsp + popq %rbp + retq + .cfi_endproc + ## -- End function + .section __TEXT,__cstring,cstring_literals +L_.str: ## @.str + .asciz "%d\n" + + +.subsections_via_symbols
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ex4-1-2.s Thu Feb 14 21:45:47 2019 +0900 @@ -0,0 +1,61 @@ + .section __TEXT,__text,regular,pure_instructions + .build_version macos, 10, 14 + .globl _main ## -- Begin function main + .p2align 4, 0x90 +_main: ## @main + .cfi_startproc +## %bb.0: + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset %rbp, -16 + movq %rsp, %rbp + .cfi_def_cfa_register %rbp + subq $16, %rsp + leaq L_.str(%rip), %rdi + + movq $3, %rax + pushq %rax + movq $2, %rax + popq %rbx + subq %rbx, %rax + pushq %rax + movq $1, %rax + popq %rbx + addq %rbx, %rax + pushq %rax + movq $0, %rax + popq %rbx + addq %rbx, %rax + pushq %rax + movq $2, %rax + pushq %rax + movq $3, %rax + popq %rbx + subq %rbx, %rax + pushq %rax + movq $1, %rax + popq %rbx + addq %rbx, %rax + pushq %rax + movq $0, %rax + popq %rbx + add %rbx, %rax + popq %rbx + subq %rbx, %rax + + movq %rax, %rsi + callq _printf + xorl %esi, %esi + movl %eax, -12(%rbp) ## 4-byte Spill + movl %esi, %eax + addq $16, %rsp + popq %rbp + retq + .cfi_endproc + ## -- End function + .section __TEXT,__cstring,cstring_literals +L_.str: ## @.str + .asciz "%d\n" + + +.subsections_via_symbols