Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Atara Razin 327348934
- .section .rodata
- strForSize: .string "%c"
- strForString: .string "%s"
- str: .string "%s"
- ########
- .text
- .globl main
- .type main,@function
- main:
- pushq %rbp #save the old frame pointer
- movq %rsp, %rbp #create the new frame pointer
- subq $2, %rsp #create two byte on the stack for the char for scanf
- movq %rsp, %r14 #have a register save its address
- movq %r14, %r15
- movq $strForSize, %rdi #first param to scanf
- movq %r14, %rsi #the address of the first char, second param
- movq $0, %rax
- call scanf
- movq $0, %rax
- addq $1, %r14
- movq $strForString, %rdi
- subq $48, (%r15)
- subb (%r15), %spl #create pstring[0] bytes of space
- subb $1, %spl
- addq $48, (%r15)
- #subq $1, %rsp
- #addq $1, %r14 #increase the pointer in order to read into slot 1 and not 0 where the size is saved
- movq %rsp, %r14 #save the bytes to the right place, right after the char of size
- movq %r14, %rsi
- movq $0, %rax
- call scanf
- movq $0, %rax
- movq (%r14), %r14
- movb $0, %r14b
- #movq $0, %rdi
- #movq $str, %rdi
- #movq $0, %rsi
- #movq %r15 ,%rsi
- #movq $0, %rax
- movq %r15, %rdi
- call swapCase
- movq $0, %rax
- movq %rbp, %rsp #restore the old stack pointer - release all used memory.
- popq %rbp #restore old frame pointer (the caller function frame)
- ret #return to caller function (OS)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement