x86汇编 - 使用加法查找权力(x86 Assembly - finding powers using addition)
该程序将接受来自用户的两个数字并显示这两个数字的总和,乘积和功率(a ^ b)。 这是捕获,但是......
程序必须:使用AddNumbers函数在MultiplyNumbers函数中使用AddNumbers函数在CalculatePower函数中使用MultiplyNumbers函数
我无法通过实现乘法加法功能找出如何找到两个数的乘积。 我无法理解它背后的逻辑。 我显然做错了什么,但我不确定是什么。 (请忽略代码的低效率,我只想知道在找到两者的产品时我做错了什么)
我的代码到目前为止..
INCLUDE Irvine32.inc .data str1 BYTE "Enter a positive integer: ",0 str2 BYTE "The sum is: ",0 str3 BYTE "The product is: ",0 str4 BYTE "The power result is: ",0 .code main PROC call GetInteger call Crlf mov eax, ebx call AddNumbers mov edx, OFFSET str2 call WriteString call WriteInt call Crlf mov eax, 0 mov ecx, edi call MultiplyNumber mov eax, edx mov edx, OFFSET str3 call WriteString call WriteInt call Crlf call CalculatePower mov eax, esi mov edx, OFFSET str4 call WriteString call WriteInt call Crlf exit main ENDP GetInteger PROC mov edx, OFFSET str1 call WriteString call ReadInt mov ebx, eax call WriteString call ReadInt mov edi, eax ret GetInteger ENDP CalculatePower PROC USES edi ebx mov ecx, edi mov esi, 0 L2: call MultiplyNumber add esi, edx loop L2 ret CalculatePower ENDP MultiplyNumber PROC USES ebx edi ecx mov edx, 0 L1: mov edi, ebx mov eax, 0 call AddNumbers add edx, eax loop L1 ret MultiplyNumber ENDP AddNumbers PROC add eax, edi ret AddNumbers ENDP END main
The program will accept two numbers from the user and display the sum, product, and power (a^b) of those two numbers. Here is the catch, however...
The program MUST: Use an AddNumbers function Use that AddNumbers function in a MultiplyNumbers function Use that MultiplyNumbers function in a CalculatePower function
I cannot figure out how to find the Product of the two numbers by implementing the multiplication through addition function. I cannot grasp the logic behind it. I'm obviously doing something wrong, but I'm not sure what. (Please ignore the inefficiency of the code, I just want to know what I'm doing wrong as far as finding the product of the two)
My code so far..
INCLUDE Irvine32.inc .data str1 BYTE "Enter a positive integer: ",0 str2 BYTE "The sum is: ",0 str3 BYTE "The product is: ",0 str4 BYTE "The power result is: ",0 .code main PROC call GetInteger call Crlf mov eax, ebx call AddNumbers mov edx, OFFSET str2 call WriteString call WriteInt call Crlf mov eax, 0 mov ecx, edi call MultiplyNumber mov eax, edx mov edx, OFFSET str3 call WriteString call WriteInt call Crlf call CalculatePower mov eax, esi mov edx, OFFSET str4 call WriteString call WriteInt call Crlf exit main ENDP GetInteger PROC mov edx, OFFSET str1 call WriteString call ReadInt mov ebx, eax call WriteString call ReadInt mov edi, eax ret GetInteger ENDP CalculatePower PROC USES edi ebx mov ecx, edi mov esi, 0 L2: call MultiplyNumber add esi, edx loop L2 ret CalculatePower ENDP MultiplyNumber PROC USES ebx edi ecx mov edx, 0 L1: mov edi, ebx mov eax, 0 call AddNumbers add edx, eax loop L1 ret MultiplyNumber ENDP AddNumbers PROC add eax, edi ret AddNumbers ENDP END main
原文:https://stackoverflow.com/questions/25840822
最满意答案
不幸的是,不,您必须为每个类别再次指定红色,绿色和蓝色值:
a { display: block; position: relative; } .brown { position: absolute; bottom: 0; background-color: rgba(118, 76, 41, 0.8); } a:hover .brown { background-color: rgba(118, 76, 41, 1); } .green { position: absolute; bottom: 0; background-color: rgba(51, 91, 11, 0.8); } a:hover .green { background-color: rgba(51, 91, 11, 1); }
您只能使用
inherit
关键字作为属性的值,即使在此处使用inherit
也不适用。This is now possible with custom properties:
.brown { --rgb: 118, 76, 41; } .green { --rgb: 51, 91, 11; } a { display: block; position: relative; } div { position: absolute; bottom: 0; background-color: rgba(var(--rgb), 0.8); } a:hover div { background-color: rgba(var(--rgb), 1); }
To understand how this works, see How do I apply opacity to a CSS color variable?
If custom properties are not an option, see the original answer below.
Unfortunately, no, you'll have to specify the red, green and blue values again for each individual class:
a { display: block; position: relative; } .brown { position: absolute; bottom: 0; background-color: rgba(118, 76, 41, 0.8); } a:hover .brown { background-color: rgba(118, 76, 41, 1); } .green { position: absolute; bottom: 0; background-color: rgba(51, 91, 11, 0.8); } a:hover .green { background-color: rgba(51, 91, 11, 1); }
You can only use the
inherit
keyword alone as a value for the property, and even then the use ofinherit
isn't appropriate here.
相关问答
更多-
问题 使用按钮本身的opacity属性会影响按钮的文本; 不理想。 解 将背景颜色应用于伪元素,并将其分层放在带有负z-index的文本下面。 需要时,使用伪元素上的opacity属性创建透明背景。 例 注意:伪元素不能应用于元素,因为它不能有子元素。 这只适用于可以拥有子元素的元素,例如
-
PeterVR的解决方案的缺点是附加的颜色显示在整个HTML块的顶部 - 这意味着它也显示在div内容之上,而不仅仅是背景图像的顶部。 如果你的div是空的,那么这是很好的,但是如果不使用线性渐变可能是一个更好的解决方案:Red text