Page 1 of 1

help me turn my code into the recursion traingle algorithm!

Posted: Sun May 15, 2022 12:30 pm
by answerhappygod
help me turn my code into the recursion traingle algorithm!
Help Me Turn My Code Into The Recursion Traingle Algorithm 1
Help Me Turn My Code Into The Recursion Traingle Algorithm 1 (67.83 KiB) Viewed 67 times
2b_pascal_triangle.asm @ + X 1 section .text 2 3 global combi ik 3 ecx in-1 6 ; ECX = n, EDX = k, returns result in EAX, no other register modified 7 ; (_msfastcall-like convention, but extended to preserve ECX+EDX) 8 combi: ; cen, k) c(n-1, k-1) + c(n-1, k), c(i, e) = c(i, i) = 1 9 test edx, edx 10 je .basecases ; c(i, e) = 1 11 стр edx, ecx ; k se n 12 je .basecases ; c(i, i) = 1 13 ; <k<n case: 14 dec 15 call combi ; EAX = c(n-1, k) 16 push esi 17 esi, eax ; keep c(n-1, k) in EST 18 dec edx 19 call combi ; EAX = c(n-1, k-1) 20 add eax,esi ; EAX = c(n-1, k-1) + c(n-1, k) 21 ; restore all modified registers 22 pop esi 23 inc 24 inc edx ret ; return result in EAX .basecases: 27 eax,1 28 ret mov ; k-1 卫四昭昭四明丑&四四四拍四四四 ecx 26 mov