Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how does SELECT CASE work, INTERNALLY?
#11
Er um I dunno.....
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#12
Code:
$ cat switch.c
int main() {

  int a = 1;

  switch(a) {
  case 1:
    a = 2;
    break;
  case 2:
  case 3:
    a = 4;
    break;
  default:
    a = -1;
    break;
  }
}

$ gcc -S switch.c
$ cat switch.s
       .file   "switch.c"
        .text
        .align 2
.globl main
        .type   main,@function
main:
        pushl   %ebp
        movl    %esp, %ebp
        subl    $8, %esp
        andl    $-16, %esp
        movl    $0, %eax
        subl    %eax, %esp
        movl    $1, -4(%ebp)
        movl    -4(%ebp), %eax
        movl    %eax, -8(%ebp)
        cmpl    $1, -8(%ebp)
        je      .L3
        cmpl    $1, -8(%ebp)
        jl      .L6
        cmpl    $3, -8(%ebp)
        jg      .L6
        jmp     .L5
.L3:
        movl    $2, -4(%ebp)
        jmp     .L2
.L5:
        movl    $4, -4(%ebp)
        jmp     .L2
.L6:
        movl    $-1, -4(%ebp)
.L2:
        leave
        ret
.Lfe1:
        .size   main,.Lfe1-main
        .ident  "GCC: (GNU) 3.2 20020903 (Red Hat Linux 8.0 3.2-7)"
esus saves.... Passes to Moses, shoots, he scores!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)