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

Latest commit

 

History

History
170 lines (158 loc) · 4 KB

p_511.md

File metadata and controls

170 lines (158 loc) · 4 KB

5.11 Compiler les appels de fonction ayant jusqu’à 6 arguments

Command for the test (source code):

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

Result:

.file  "p_511.c"
.text

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


foo:
  pushq   %rbp
  movq    %rsp, %rbp
  subq $100, %rsp

  movl    %edi, -4(%rbp)                 # copyInstr
  movl    %esi, -8(%rbp)                 # copyInstr
  movl    %edx, -12(%rbp)                 # copyInstr
  movl    %ecx, -16(%rbp)                 # copyInstr
  movl    %r8d, -20(%rbp)                 # copyInstr
  movl    %r9d, -24(%rbp)                 # copyInstr
  jmp    .L1_innerbeginof_foo

.L1_innerbeginof_foo:
  movl    $48, -32(%rbp)
  # empty with returnName=a
  movl    -4(%rbp), %r10d
  movl    %r10d, -36(%rbp)
  movl    -32(%rbp), %eax
  addl    %eax, -36(%rbp)
  pushq    %rdi
  movl    -36(%rbp), %edi                 # call Param
  call    putchar
  popq     %rdi
  movl    $48, -44(%rbp)
  # empty with returnName=b
  movl    -8(%rbp), %r10d
  movl    %r10d, -48(%rbp)
  movl    -44(%rbp), %eax
  addl    %eax, -48(%rbp)
  pushq    %rdi
  movl    -48(%rbp), %edi                 # call Param
  call    putchar
  popq     %rdi
  movl    $48, -56(%rbp)
  # empty with returnName=c
  movl    -12(%rbp), %r10d
  movl    %r10d, -60(%rbp)
  movl    -56(%rbp), %eax
  addl    %eax, -60(%rbp)
  pushq    %rdi
  movl    -60(%rbp), %edi                 # call Param
  call    putchar
  popq     %rdi
  movl    $48, -68(%rbp)
  # empty with returnName=d
  movl    -16(%rbp), %r10d
  movl    %r10d, -72(%rbp)
  movl    -68(%rbp), %eax
  addl    %eax, -72(%rbp)
  pushq    %rdi
  movl    -72(%rbp), %edi                 # call Param
  call    putchar
  popq     %rdi
  movl    $48, -80(%rbp)
  # empty with returnName=e
  movl    -20(%rbp), %r10d
  movl    %r10d, -84(%rbp)
  movl    -80(%rbp), %eax
  addl    %eax, -84(%rbp)
  pushq    %rdi
  movl    -84(%rbp), %edi                 # call Param
  call    putchar
  popq     %rdi
  movl    $48, -92(%rbp)
  # empty with returnName=f
  movl    -24(%rbp), %r10d
  movl    %r10d, -96(%rbp)
  movl    -92(%rbp), %eax
  addl    %eax, -96(%rbp)
  pushq    %rdi
  movl    -96(%rbp), %edi                 # call Param
  call    putchar
  popq     %rdi
  # empty with returnName=d
  movl    -16(%rbp), %eax
  jmp    .L0_endof_foo
  jmp    .L0_endof_foo

.L0_endof_foo:
  leave
  ret

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

  jmp    .L3_innerbeginof_main

.L3_innerbeginof_main:
  movl    $79, -8(%rbp)
  movl    $6, -16(%rbp)
  pushq    %r9
  movl    -16(%rbp), %r9d                 # call Param
  movl    $5, -24(%rbp)
  pushq    %r8
  movl    -24(%rbp), %r8d                 # call Param
  movl    $4, -32(%rbp)
  pushq    %rcx
  movl    -32(%rbp), %ecx                 # call Param
  movl    $3, -40(%rbp)
  pushq    %rdx
  movl    -40(%rbp), %edx                 # call Param
  movl    $2, -48(%rbp)
  pushq    %rsi
  movl    -48(%rbp), %esi                 # call Param
  movl    $1, -56(%rbp)
  pushq    %rdi
  movl    -56(%rbp), %edi                 # call Param
  call    foo
  movl    %eax, -60(%rbp)
  popq     %rdi
  popq     %rsi
  popq     %rdx
  popq     %rcx
  popq     %r8
  popq     %r9
  movl    -8(%rbp), %eax
  subl    -60(%rbp), %eax
  movl    %eax, -64(%rbp)
  movl    -64(%rbp), %r10d
  movl    %r10d, -68(%rbp)                 # copyInstr
  movl    $10, -76(%rbp)
  pushq    %rdi
  movl    -76(%rbp), %edi                 # call Param
  call    putchar
  popq     %rdi
  movl    $79, -84(%rbp)
  pushq    %rdi
  movl    -84(%rbp), %edi                 # call Param
  call    putchar
  popq     %rdi
  # empty with returnName=k
  pushq    %rdi
  movl    -68(%rbp), %edi                 # call Param
  call    putchar
  popq     %rdi
  movl    $10, -92(%rbp)
  pushq    %rdi
  movl    -92(%rbp), %edi                 # call Param
  call    putchar
  popq     %rdi
  movl    $0, -100(%rbp)
  movl    -100(%rbp), %eax
  jmp    .L2_endof_main
  jmp    .L2_endof_main

.L2_endof_main:
  leave
  ret