edit— figured it out. I think I was killing my loop in .L1 by comparing before calling sla.
I'm really struggling with an assignment right now-- hoping to get some advice from someone knowledgeable. I'm expecting this nested for loop to return 256, but in many cases it returns 0 for seemingly no reason. The lines with the exclamation marks cause my program to return 0 if not commented out, but I absolutely can't figure out why. I'm assembling with as and compiling with gcc.
Tyvm. @Sythe
I'm really struggling with an assignment right now-- hoping to get some advice from someone knowledgeable. I'm expecting this nested for loop to return 256, but in many cases it returns 0 for seemingly no reason. The lines with the exclamation marks cause my program to return 0 if not commented out, but I absolutely can't figure out why. I'm assembling with as and compiling with gcc.
Tyvm. @Sythe
Code:
#for loop from 0 to 256
fla:
cmpq $256, %r10
jl .L1
movq %r10, %rax
ret
.L1:
addq $1, %r10
cmpq $256, %r10
movq %r10, %rdi #used to send value of r10 to nested for loop
call sla
jl .L1
ret
#for loop from 8 to 0
sla:
movq $8 , %r12
cmpq $0 , %r12 !!!!!
jne .L2 !!!!!
ret
.L2:
subq $1 , %r12
cmpq $0 , %r12
jne .L2
ret
Last edited:
































