Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .text
- s1: .asciz "Hi,_this_is_a_testfile.\nTestfile_1_to_be_precise."
- s2: .asciz "Hi, this is a testfile.\nTestfile_2_to_be_precise."
- formatstr: .asciz "%d\n"
- formatstr2:.asciz "%s\n"
- .global main
- main:
- pushq %rbp
- movq %rsp, %rbp
- movq $s1,%r12 #load the strings to registers
- movq $s2,%r13 #>>
- movq $0,%rbx #initialise i
- call loop
- jmp end
- movq %rbp,%rsp
- popq %rbp
- loop:
- pushq %rbp
- movq %rsp, %rbp
- mov (%r12,%rbx),%al #move each charatcter of the 1st string to the lowest memory
- mov (%r13,%rbx),%bl #>> >> 2nd >>
- incq %rbx #increment pointer for the next letter
- cmp %al,%bl #compare the two letters
- jne notequal #if not equal then the two strings are different, so
- cmp $0,%al #compare 0 with al to realise the end of the string
- je end
- jmp loop
- movq %rbp,%rsp
- popq %rbp
- notequal:
- pushq %rbp
- movq %rsp, %rbp
- movq $formatstr,%rdi
- movq %rbx,%rsi
- movq $0,%rax
- call printf
- jmp loop
- movq %rbp,%rsp
- popq %rbp
- end:
- movq $0,%rdi
- call exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement