Advertisement
Guest User

Untitled

a guest
Dec 30th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Atara Razin 327348934
  2.  
  3.     .section    .rodata
  4. strForSize: .string "%c"
  5. strForString:   .string "%s"
  6. str:        .string "%s"
  7.     ########
  8.     .text
  9. .globl main
  10.     .type main,@function
  11. main:
  12.     pushq   %rbp            #save the old frame pointer
  13.     movq    %rsp, %rbp      #create the new frame pointer
  14.     subq    $2, %rsp        #create two byte on the stack for the char for scanf
  15.     movq    %rsp, %r14      #have a register save its address
  16.     movq    %r14, %r15
  17.        
  18.     movq    $strForSize, %rdi   #first param to scanf
  19.     movq    %r14, %rsi      #the address of the first char, second param
  20.     movq    $0, %rax   
  21.     call    scanf
  22.     movq    $0, %rax
  23.  
  24.     addq    $1, %r14
  25.  
  26.     movq    $strForString, %rdi
  27.     subq    $48, (%r15)
  28.     subb    (%r15), %spl        #create pstring[0] bytes of space
  29.     subb    $1, %spl
  30.     addq    $48, (%r15)
  31.     #subq   $1, %rsp   
  32.     #addq   $1, %r14        #increase the pointer in order to read into slot 1 and not 0 where the size is saved
  33.     movq    %rsp, %r14      #save the bytes to the right place, right after the char of size
  34.     movq    %r14, %rsi     
  35.     movq    $0, %rax   
  36.     call    scanf
  37.     movq    $0, %rax
  38.     movq    (%r14), %r14
  39.     movb    $0, %r14b
  40.  
  41.     #movq   $0, %rdi
  42.     #movq   $str, %rdi
  43.     #movq   $0, %rsi
  44.     #movq   %r15 ,%rsi
  45.     #movq   $0, %rax
  46.     movq    %r15, %rdi 
  47.     call    swapCase   
  48.     movq    $0, %rax
  49.  
  50.     movq    %rbp, %rsp  #restore the old stack pointer - release all used memory.
  51.     popq    %rbp        #restore old frame pointer (the caller function frame)
  52.     ret         #return to caller function (OS)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement