Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .section .rodata
- .align 8
- .jumpTable:
- .quad .option50
- .quad .option51
- .quad .option52
- .quad .option53
- .quad .option54
- .quad .defaultOption
- strFormatForScanf: .string "%c"
- str: .string "In run_func\n"
- stringForStrlen: .string "first pstring length: %d, second pstring length: %d\n"
- strForSwapCase: .string "length: , string: %s\n"
- ########
- .text
- .global run_func
- .type run_func,@function
- run_func:
- pushq %rbp #save the old frame pointer
- movq %rsp, %rbp #create the new frame pointer
- movq %rsi, %r12 #save the first pstring in a caller saver register
- movq %rdx, %r13 #save the second pstring in a caller saver register
- subq $50, %rdi
- cmpq $5, %rdi
- ja .defaultOption
- jmp *.jumpTable(,%rdi,8)
- .option50:
- movq %r12, %rdi #send the first pstring as a parameter to pstrlen
- call pstrlen
- movq %rax, %rsi #move the return value into the second parameter for printf
- movq %r13, %rdi #send the second pstring as a parameter to pstrlen
- call pstrlen
- movq %rax, %rdx #move the return value into the thrid parameter to printf
- movq $stringForStrlen, %rdi #save the string as the first parameter to printf
- movq $0, %rax
- call printf
- movq $0, %rax
- jmp .defaultOption
- .option51:
- movq %r12 ,%rdi
- #call replaceChar
- subq $1, %rsp
- movq %rsp, %r14
- subq $1, %rsp
- movq %rsp, %r15
- movq $strFormatForScanf, %rdi #first param to scanf
- movq %r14, %rsi
- #subq $2, %rsp #increase the stack
- #movq 1(%rsp), %rsi #second param to scanf
- movq $0, %rax
- call scanf
- movq $0, %rax
- call replaceChar
- #movq $0, %rax
- #movq $delete, %rdi #first param to printf
- #movq 4(%rsp), %rsi #second param to printf
- #movq $0, %rax
- #call printf
- jmp .defaultOption
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement