ccmny

jump tables

Sep 16th, 2011
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     .file   "jmptab.c"
  2.     .def    ___main;    .scl    2;  .type   32; .endef
  3.     .section .rdata,"dr"
  4. LC0:
  5.     .ascii "Input: \0"
  6. LC1:
  7.     .ascii "a\0"
  8. LC2:
  9.     .ascii "b\0"
  10. LC3:
  11.     .ascii "c\0"
  12. LC4:
  13.     .ascii "default\0"
  14.     .text
  15. .globl _main
  16.     .def    _main;  .scl    2;  .type   32; .endef
  17. _main:
  18.     pushl   %ebp
  19.     movl    %esp, %ebp
  20.     andl    $-16, %esp
  21.     subl    $32, %esp
  22.     call    ___main
  23.     movl    $LC0, (%esp)
  24.     call    _printf
  25.     call    _getchar
  26.     movb    %al, 31(%esp)
  27.     movsbl  31(%esp), %eax
  28.     cmpl    $98, %eax
  29.     je  L4
  30.     cmpl    $99, %eax
  31.     je  L5
  32.     cmpl    $97, %eax
  33.     jne L7
  34. L3:
  35.     movl    $LC1, (%esp)
  36.     call    _puts
  37.     jmp L8
  38. L4:
  39.     movl    $LC2, (%esp)
  40.     call    _puts
  41.     jmp L8
  42. L5:
  43.     movl    $LC3, (%esp)
  44.     call    _puts
  45.     jmp L8
  46. L7:
  47.     movl    $LC4, (%esp)
  48.     call    _puts
  49.     nop
  50. L8:
  51.     leave
  52.     ret
  53.     .def    _puts;  .scl    2;  .type   32; .endef
  54.     .def    _printf;    .scl    2;  .type   32; .endef
  55.     .def    _getchar;   .scl    2;  .type   32; .endef
Advertisement
Add Comment
Please, Sign In to add comment