Advertisement
Guest User

Untitled

a guest
Oct 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. .text
  2. s1: .asciz "Hi,_this_is_a_testfile.\nTestfile_1_to_be_precise."
  3. s2: .asciz "Hi, this is a testfile.\nTestfile_2_to_be_precise."
  4. formatstr: .asciz "%d\n"
  5. formatstr2:.asciz "%s\n"
  6.  
  7. .global main
  8.  
  9. main:
  10. pushq %rbp
  11. movq %rsp, %rbp
  12.  
  13. movq $s1,%r12 #load the strings to registers
  14. movq $s2,%r13 #>>
  15. movq $0,%rbx #initialise i
  16. call loop
  17. jmp end
  18.  
  19. movq %rbp,%rsp
  20. popq %rbp
  21. loop:
  22. pushq %rbp
  23. movq %rsp, %rbp
  24.  
  25. mov (%r12,%rbx),%al #move each charatcter of the 1st string to the lowest memory
  26. mov (%r13,%rbx),%bl #>> >> 2nd >>
  27. incq %rbx #increment pointer for the next letter
  28. cmp %al,%bl #compare the two letters
  29. jne notequal #if not equal then the two strings are different, so
  30.  
  31.  
  32.  
  33. cmp $0,%al #compare 0 with al to realise the end of the string
  34. je end
  35.  
  36. jmp loop
  37.  
  38. movq %rbp,%rsp
  39. popq %rbp
  40. notequal:
  41. pushq %rbp
  42. movq %rsp, %rbp
  43.  
  44. movq $formatstr,%rdi
  45. movq %rbx,%rsi
  46. movq $0,%rax
  47. call printf
  48.  
  49. jmp loop
  50.  
  51. movq %rbp,%rsp
  52. popq %rbp
  53. end:
  54.  
  55. movq $0,%rdi
  56. call exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement