diff options
| author | Bond_009 <bond.009@outlook.com> | 2020-12-26 23:08:46 +0100 |
|---|---|---|
| committer | Bond_009 <bond.009@outlook.com> | 2020-12-26 23:08:46 +0100 |
| commit | 89ab7b172bfda17ddfd3395b9c7a157b32a52609 (patch) | |
| tree | 7c3a0f8b7b35edebbd93c2929c64bbb5351c7ec5 /10/possible_seq.asm | |
| parent | 9ebb70dd2a57d4b2ac4b53efa644a77b6079fc2c (diff) | |
Add partial assembly sollution for day 10
Diffstat (limited to '10/possible_seq.asm')
| -rw-r--r-- | 10/possible_seq.asm | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/10/possible_seq.asm b/10/possible_seq.asm new file mode 100644 index 0000000..15c6586 --- /dev/null +++ b/10/possible_seq.asm @@ -0,0 +1,30 @@ +global possible_seq + +section .data + TRIB: dq 1, 1, 2, 4, 7 ; tribonacci sequence (without first 2 zeroes) + +section .text + +possible_seq: + mov eax, 1 ; set up return value + xor ecx, ecx ; # of connected elements counter + lea rdx, [rdi + 4 * rsi - 4] ; pointer to the last element + lea r8, [rel TRIB] + jmp .loop +.ncon: + imul rax, qword [r8 + 8 * rcx] + xor ecx, ecx + add rdi, 4 + cmp rdi, rdx + jae .return +.loop: + mov esi, dword [rdi + 4] + sub esi, dword [rdi] + cmp esi, 1 + jne .ncon + inc ecx + add rdi, 4 + cmp rdi, rdx + jb .loop +.return: + ret |
