I'm new to assembly and I'm doing this for school. It's segfaulting on line 16 (cmpq) even though from what I understand I'm doing this correctly. Thanks in advance.
global transitions
.text
transitions:
push %rbp #Push old frame pointer to stack
movq %rsp, %rbp #Update rbp so that its pointing at the old rbp (which is the bottom of the new frame)
pushq %r12 #save r12
pushq %r13 #save r13
pushq %rax #save return value
movq $0, %r12 #set shift count to 0
movq $0, %rax #set transitions to 0
movq %r13, %rdi #copy perameter
shlq %r13 #Initialize carry flag
start:
incq %r12 #Increment shifts
cmpq %r12, 63 #See if shift count is greater than 63
jns end #Jump to end if true
shl %r14 #Shift left
jnc start #Jump to start if bit was 0
incq %r12 #Increment shifts
cmpq %r12, 63 #See if shift count is greater than 63
jns end #Jump to end if true
shl %r14 #Shift left
jnc found #See if sequence is found
jmp start#Jump to start
found:
incq %rax #increment transitions
end:
pop %r14
pop %rax
pop %r13
pop %r12
ret
Edit: Shoutout to lurker and Nate in the comments. Thanks!