Обновить lad1/README.md
This commit is contained in:
+19
-5
@@ -94,7 +94,9 @@ base + index × scale + displacement
|
||||
|
||||
Умножение на 3
|
||||
|
||||
long mul3(long x) {
|
||||
long mul3(long x)
|
||||
|
||||
{
|
||||
|
||||
return x * 3;
|
||||
}
|
||||
@@ -112,7 +114,9 @@ rax = rdi + rdi × 2
|
||||
|
||||
Умножение на 5
|
||||
|
||||
long mul5(long x) {
|
||||
long mul5(long x)
|
||||
|
||||
{
|
||||
|
||||
return x * 5;
|
||||
|
||||
@@ -127,11 +131,17 @@ x + 4x = 5x
|
||||
|
||||
Умножение на 9
|
||||
|
||||
long mul9(long x) {
|
||||
long mul9(long x)
|
||||
|
||||
{
|
||||
|
||||
return x * 9;
|
||||
|
||||
}
|
||||
|
||||
|
||||
lea rax, [rdi + rdi*8]
|
||||
|
||||
ret
|
||||
|
||||
То есть:
|
||||
@@ -162,10 +172,14 @@ lea rax, [rdi - 8]
|
||||
|
||||
Используем функцию факториала:
|
||||
|
||||
long factorial(int n) {
|
||||
long factorial(int n)
|
||||
|
||||
{
|
||||
long result = 1;
|
||||
|
||||
for (int i = 2; i <= n; i++) {
|
||||
for (int i = 2; i <= n; i++)
|
||||
|
||||
{
|
||||
result *= i;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user