Q1: AX contains a non-zer number. Count the number ofones it and the result back
ID: 3615873 • Letter: Q
Question
Q1: AX contains a non-zer number. Count the number ofones it and the result back in ax. Repeat the proccess on theresult (AX) until AX contains one. For Example BX should contain 2in the following case. AX= 1100 0101 1010 0011 (input - 8 ones) AX = 0000 0000 0000 1000 (after first iteration - 1 one) AX = 0000 0000 0000 0001 (after second Iteration) STOP Q2: write a program in Assembly language to calculatethe factorial of a number. Where factorial is: factorial (x) = x * (x-1)* (x-2) *.....1 factorial (0)= 1 Q1: AX contains a non-zer number. Count the number ofones it and the result back in ax. Repeat the proccess on theresult (AX) until AX contains one. For Example BX should contain 2in the following case. AX= 1100 0101 1010 0011 (input - 8 ones) AX = 0000 0000 0000 1000 (after first iteration - 1 one) AX = 0000 0000 0000 0001 (after second Iteration) STOP Q2: write a program in Assembly language to calculatethe factorial of a number. Where factorial is: factorial (x) = x * (x-1)* (x-2) *.....1 factorial (0)= 1Explanation / Answer
factorial: pushl %ebp movl %esp, %ebp movl 8(%ebp), %eax cmpl $1, %eax je end_factorial decl %eax pushl %eax call factorial movl 8(%ebp), %ebx imull %ebx, %eax end_factorial: movl %ebp, %esp popl %ebp ret
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.