Skip to content
This repository has been archived by the owner on Dec 12, 2022. It is now read-only.

Latest commit

 

History

History
82 lines (70 loc) · 1.47 KB

p_58.md

File metadata and controls

82 lines (70 loc) · 1.47 KB

5.8 "Compiler le retour de valeur"

Command to run the test (source code):

./chef.py test backend -bw doc/p_58.c
cat build/cpp-bin/assembly.s

Result:

.file  "p_58.c"
.text

.Ltext0:
  .globl main
  .type main, @function


ret4:
  pushq   %rbp
  movq    %rsp, %rbp
  subq $16, %rsp

  jmp    .L1_innerbeginof_ret4

.L1_innerbeginof_ret4:
  movl    $4, -8(%rbp)
  movl    -8(%rbp), %eax
  jmp    .L0_endof_ret4
  jmp    .L0_endof_ret4

.L0_endof_ret4:
  leave
  ret

main:
  pushq   %rbp
  movq    %rsp, %rbp
  subq $68, %rsp

  jmp    .L3_innerbeginof_main

.L3_innerbeginof_main:
  movl    $79, -8(%rbp)
  movl    $4, -16(%rbp)
  movl    -8(%rbp), %eax
  subl    -16(%rbp), %eax
  movl    %eax, -20(%rbp)
  call    ret4
  movl    %eax, -24(%rbp)
  movl    -24(%rbp), %r10d
  movl    %r10d, -28(%rbp)
  movl    -20(%rbp), %eax
  addl    %eax, -28(%rbp)
  pushq    %rdi
  movl    -28(%rbp), %edi                 # call Param
  call    putchar
  popq     %rdi
  movl    $79, -36(%rbp)
  call    ret4
  movl    %eax, -40(%rbp)
  movl    -36(%rbp), %eax
  subl    -40(%rbp), %eax
  movl    %eax, -44(%rbp)
  pushq    %rdi
  movl    -44(%rbp), %edi                 # call Param
  call    putchar
  popq     %rdi
  movl    $10, -52(%rbp)
  pushq    %rdi
  movl    -52(%rbp), %edi                 # call Param
  call    putchar
  popq     %rdi
  movl    $0, -60(%rbp)
  movl    -60(%rbp), %eax
  jmp    .L2_endof_main
  jmp    .L2_endof_main

.L2_endof_main:
  leave
  ret