diff options
Diffstat (limited to '3/6_control/30_switch2.c')
| -rw-r--r-- | 3/6_control/30_switch2.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/3/6_control/30_switch2.c b/3/6_control/30_switch2.c new file mode 100644 index 0000000..0c8cc85 --- /dev/null +++ b/3/6_control/30_switch2.c @@ -0,0 +1,37 @@ +#include <stdio.h> + +// x in %rdi +// switch2: +// addq $1, %rdi +// cmpq $8, %rdi +// ja .L2 if (x + 1) > 8 then goto default +// jmp *.L4(,%rdi,8) take the address at x*8 from .L4 +void switch2(long x, long *dest) { + long val = 0; + switch (x) { + case -1: + printf(".L9"); + break; + case 0: + case 7: + printf(".L5"); + break; + case 1: + printf(".L6"); + break; + case 2: + case 4: + printf(".L7"); + break; + case 5: + printf(".L8"); + break; + + } + *dest = val; +} + +int main(void) { + printf("val: %ld\n"); + return 0; +} |
