flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
bitRAKE 08 Jun 2009, 04:10
Number of possible combinations from a set.
Code: Choose: ; RDX in range [0,RCX] mov r9,rcx sub r9,rdx jc .err push 0 1 pop rax r8 ; reduce, R9 = MIN(RDX,R9) cmp rdx,r9 cmovc r9,rdx jmp .1 .0: inc r8 mul rcx dec rcx ; RDX in range [0,R8) cmp rdx,r8 jnc .err div r8 .1: cmp r8,r9 jc .0 ; RAX = RCX choose RDX retn .err: xor eax,eax stc retn This uses a method to generate individual rows of Pascal's triangle. Code: push 52 5 pop rdx rcx call Choose jc .error _________________ ¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.