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

Latest commit

 

History

History
81 lines (68 loc) · 1.41 KB

p_56.md

File metadata and controls

81 lines (68 loc) · 1.41 KB

5.6 "Compiler le if ... else"

Command to run the test (source code):

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

Result :

.file  "p_56.c"
.text

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


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

  jmp    .L1_innerbeginof_main

.L1_innerbeginof_main:
  jmp    .L2_cond

.L2_cond:
  movl    $1, -8(%rbp)
  movl    $2, -16(%rbp)
  movl    -16(%rbp), %r10d
  cmp    %r10d, -8(%rbp)
  setl    %cl
  movzbl    %cl, %r10d
  movl    %r10d, -20(%rbp)
  cmpl    $0, -20(%rbp)
  je    .L4_else
  jmp    .L3_then

.L3_then:
  movl    $79, -28(%rbp)
  pushq    %rdi
  movl    -28(%rbp), %edi                 # call Param
  call    putchar
  popq     %rdi
  movl    $75, -36(%rbp)
  pushq    %rdi
  movl    -36(%rbp), %edi                 # call Param
  call    putchar
  popq     %rdi
  jmp    .L5_end

.L4_else:
  movl    $75, -44(%rbp)
  pushq    %rdi
  movl    -44(%rbp), %edi                 # call Param
  call    putchar
  popq     %rdi
  movl    $79, -52(%rbp)
  pushq    %rdi
  movl    -52(%rbp), %edi                 # call Param
  call    putchar
  popq     %rdi
  jmp    .L5_end

.L5_end:
  jmp    .L6_funcinnerafter

.L6_funcinnerafter:
  movl    $10, -60(%rbp)
  pushq    %rdi
  movl    -60(%rbp), %edi                 # call Param
  call    putchar
  popq     %rdi
  jmp    .L0_endof_main

.L0_endof_main:
  leave
  ret